Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1068)

Side by Side Diff: base/trace_event/heap_profiler_allocation_context_tracker.h

Issue 1900223003: [tracing] Ignore tracing allocations in heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make heap_profiler.h and rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Returns the thread-local instance, creating one if necessary. Returns 46 // Returns the thread-local instance, creating one if necessary. Returns
47 // always a valid instance, unless it is called re-entrantly, in which case 47 // always a valid instance, unless it is called re-entrantly, in which case
48 // returns nullptr in the nested calls. 48 // returns nullptr in the nested calls.
49 static AllocationContextTracker* GetInstanceForCurrentThread(); 49 static AllocationContextTracker* GetInstanceForCurrentThread();
50 50
51 // Set the thread name in the AllocationContextTracker of the current thread 51 // Set the thread name in the AllocationContextTracker of the current thread
52 // if capture is enabled. 52 // if capture is enabled.
53 static void SetCurrentThreadName(const char* name); 53 static void SetCurrentThreadName(const char* name);
54 54
55 // Starts and ends a new ignore scope between which the allocations are
56 // ignored in the heap profiler. A dummy context that short circuits to
57 // "tracing_overhead" is returned for these allocations.
58 void begin_ignore_scope() { ignore_scope_depth_++; }
59 void end_ignore_scope() {
60 if (ignore_scope_depth_)
61 ignore_scope_depth_--;
62 }
63
55 // Pushes a frame onto the thread-local pseudo stack. 64 // Pushes a frame onto the thread-local pseudo stack.
56 void PushPseudoStackFrame(const char* trace_event_name); 65 void PushPseudoStackFrame(const char* trace_event_name);
57 66
58 // Pops a frame from the thread-local pseudo stack. 67 // Pops a frame from the thread-local pseudo stack.
59 void PopPseudoStackFrame(const char* trace_event_name); 68 void PopPseudoStackFrame(const char* trace_event_name);
60 69
61 // Push and pop current task's context. A stack is used to support nested 70 // Push and pop current task's context. A stack is used to support nested
62 // tasks and the top of the stack will be used in allocation context. 71 // tasks and the top of the stack will be used in allocation context.
63 void PushCurrentTaskContext(const char* context); 72 void PushCurrentTaskContext(const char* context);
64 void PopCurrentTaskContext(const char* context); 73 void PopCurrentTaskContext(const char* context);
(...skipping 11 matching lines...) Expand all
76 // The pseudo stack where frames are |TRACE_EVENT| names. 85 // The pseudo stack where frames are |TRACE_EVENT| names.
77 std::vector<const char*> pseudo_stack_; 86 std::vector<const char*> pseudo_stack_;
78 87
79 // The thread name is used as the first entry in the pseudo stack. 88 // The thread name is used as the first entry in the pseudo stack.
80 const char* thread_name_; 89 const char* thread_name_;
81 90
82 // Stack of tasks' contexts. Context serves as a different dimension than 91 // Stack of tasks' contexts. Context serves as a different dimension than
83 // pseudo stack to cluster allocations. 92 // pseudo stack to cluster allocations.
84 std::vector<const char*> task_contexts_; 93 std::vector<const char*> task_contexts_;
85 94
95 uint32_t ignore_scope_depth_;
96
86 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); 97 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker);
87 }; 98 };
88 99
89 } // namespace trace_event 100 } // namespace trace_event
90 } // namespace base 101 } // namespace base
91 102
92 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ 103 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698