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

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

Issue 2089253002: [tracing] Optimize AllocationRegister and increase max backtrace depth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 5 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_H_ 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool BASE_EXPORT operator < (const StackFrame& lhs, const StackFrame& rhs); 64 bool BASE_EXPORT operator < (const StackFrame& lhs, const StackFrame& rhs);
65 bool BASE_EXPORT operator == (const StackFrame& lhs, const StackFrame& rhs); 65 bool BASE_EXPORT operator == (const StackFrame& lhs, const StackFrame& rhs);
66 bool BASE_EXPORT operator != (const StackFrame& lhs, const StackFrame& rhs); 66 bool BASE_EXPORT operator != (const StackFrame& lhs, const StackFrame& rhs);
67 67
68 struct BASE_EXPORT Backtrace { 68 struct BASE_EXPORT Backtrace {
69 Backtrace(); 69 Backtrace();
70 70
71 // If the stack is higher than what can be stored here, the bottom frames 71 // If the stack is higher than what can be stored here, the bottom frames
72 // (the ones closer to main()) are stored. Depth of 12 is enough for most 72 // (the ones closer to main()) are stored. Depth of 12 is enough for most
73 // pseudo traces (see above), but not for native traces, where we need more. 73 // pseudo traces (see above), but not for native traces, where we need more.
74 enum { kMaxFrameCount = 24 }; 74 enum { kMaxFrameCount = 48 };
75 StackFrame frames[kMaxFrameCount]; 75 StackFrame frames[kMaxFrameCount];
76 size_t frame_count; 76 size_t frame_count;
77 }; 77 };
78 78
79 bool BASE_EXPORT operator==(const Backtrace& lhs, const Backtrace& rhs); 79 bool BASE_EXPORT operator==(const Backtrace& lhs, const Backtrace& rhs);
80 bool BASE_EXPORT operator!=(const Backtrace& lhs, const Backtrace& rhs);
80 81
81 // The |AllocationContext| is context metadata that is kept for every allocation 82 // The |AllocationContext| is context metadata that is kept for every allocation
82 // when heap profiling is enabled. To simplify memory management for book- 83 // when heap profiling is enabled. To simplify memory management for book-
83 // keeping, this struct has a fixed size. 84 // keeping, this struct has a fixed size.
84 struct BASE_EXPORT AllocationContext { 85 struct BASE_EXPORT AllocationContext {
85 AllocationContext(); 86 AllocationContext();
87 AllocationContext(const Backtrace& backtrace, const char* type_name);
86 88
87 Backtrace backtrace; 89 Backtrace backtrace;
88 90
89 // Type name of the type stored in the allocated memory. A null pointer 91 // Type name of the type stored in the allocated memory. A null pointer
90 // indicates "unknown type". Grouping is done by comparing pointers, not by 92 // indicates "unknown type". Grouping is done by comparing pointers, not by
91 // deep string comparison. In a component build, where a type name can have a 93 // deep string comparison. In a component build, where a type name can have a
92 // string literal in several dynamic libraries, this may distort grouping. 94 // string literal in several dynamic libraries, this may distort grouping.
93 const char* type_name; 95 const char* type_name;
94 }; 96 };
95 97
96 bool BASE_EXPORT operator==(const AllocationContext& lhs, 98 bool BASE_EXPORT operator==(const AllocationContext& lhs,
97 const AllocationContext& rhs); 99 const AllocationContext& rhs);
100 bool BASE_EXPORT operator!=(const AllocationContext& lhs,
101 const AllocationContext& rhs);
98 102
99 // Struct to store the size and count of the allocations. 103 // Struct to store the size and count of the allocations.
100 struct AllocationMetrics { 104 struct AllocationMetrics {
101 size_t size; 105 size_t size;
102 size_t count; 106 size_t count;
103 }; 107 };
104 108
105 } // namespace trace_event 109 } // namespace trace_event
106 } // namespace base 110 } // namespace base
107 111
(...skipping 10 matching lines...) Expand all
118 }; 122 };
119 123
120 template <> 124 template <>
121 struct BASE_EXPORT hash<base::trace_event::AllocationContext> { 125 struct BASE_EXPORT hash<base::trace_event::AllocationContext> {
122 size_t operator()(const base::trace_event::AllocationContext& context) const; 126 size_t operator()(const base::trace_event::AllocationContext& context) const;
123 }; 127 };
124 128
125 } // BASE_HASH_NAMESPACE 129 } // BASE_HASH_NAMESPACE
126 130
127 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ 131 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698