Commit 3565e305 authored by Siddhartha S's avatar Siddhartha S Committed by Commit Bot

Put all untracked tasks in a single bucket in memory infra

IPC messages sometimes show up under wrong bucket since the original
task that posted is empty. This will ensure that we can differentiate
between messages sent by the channel itself, vs the messages sent by
untracked tasks.

Change-Id: I6b6410959c2040b55e519f5c26b8081d61fa22c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1641807Reviewed-by: default avataroysteine <oysteine@chromium.org>
Commit-Queue: ssid <ssid@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667335}
parent 98834bac
......@@ -97,6 +97,7 @@ AllocationContextTracker::AllocationContextTracker()
: thread_name_(nullptr), ignore_scope_depth_(0) {
tracked_stack_.reserve(kMaxStackDepth);
task_contexts_.reserve(kMaxTaskDepth);
task_contexts_.push_back("UntrackedTask");
}
AllocationContextTracker::~AllocationContextTracker() = default;
......@@ -163,8 +164,8 @@ void AllocationContextTracker::PushCurrentTaskContext(const char* context) {
void AllocationContextTracker::PopCurrentTaskContext(const char* context) {
// Guard for stack underflow. If tracing was started with a TRACE_EVENT in
// scope, the context was never pushed, so it is possible that pop is called
// on an empty stack.
if (task_contexts_.empty())
// on an empty stack. Note that the context always contains "UntrackedTask".
if (task_contexts_.size() == 1)
return;
DCHECK_EQ(context, task_contexts_.back())
......
......@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
#include "base/pending_task.h"
#include "base/strings/string_piece.h"
#include "base/trace_event/heap_profiler.h"
#include "base/trace_event/heap_profiler_allocation_context.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
......@@ -334,7 +335,7 @@ TEST_F(AllocationContextTrackerTest, TrackCategoryName) {
AllocationContext ctx;
ASSERT_TRUE(AllocationContextTracker::GetInstanceForCurrentThread()
->GetContextSnapshot(&ctx));
ASSERT_FALSE(ctx.type_name);
ASSERT_EQ("UntrackedTask", base::StringPiece(ctx.type_name));
}
TEST_F(AllocationContextTrackerTest, IgnoreAllocationTest) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment