|
|
Chromium Code Reviews|
Created:
5 years, 3 months ago by Ruud van Asseldonk Modified:
5 years, 2 months ago CC:
chromium-reviews, darin-cc_chromium.org, jam, tracing+reviews_chromium.org, wfh+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionThis introduces a thread-local context that can be used for heap
profiling. It contains a pseudo stack where trace events are the
stack frames. There is a fast early-out in case capturing context
is disabled.
This is a prerequisite for the heap profiler in chrome://tracing. It
will log allocations with context obtained from the system introduced
here.
This is intended to replace the tcmalloc-specific heap profiler in
base/trace_event/trace_event_memory and its pseudo stack once the heap
profiler lands.
BUG=524631
Committed: https://crrev.com/abff8221c8d35916a8d7e12845ba61bc5c48aff8
Cr-Commit-Position: refs/heads/master@{#350799}
Patch Set 1 #Patch Set 2 : Fix typo #
Total comments: 7
Patch Set 3 : Address picksi comments #Patch Set 4 : Remove PseudoStackController #Patch Set 5 : Do not use C++11 <iterator> #Patch Set 6 : Do not allow frame metadata, hook begin/end macros #
Total comments: 15
Patch Set 7 : Address dsinclair comments #Patch Set 8 : Put pseudo stack in TLS context #Patch Set 9 : Make MSVC and Clang on Mac happy #Patch Set 10 : Try to make MSVC happy #
Total comments: 42
Patch Set 11 : Address primiano comments #
Total comments: 30
Patch Set 12 : Address primiano comments #Patch Set 13 : Remove generation counter #
Total comments: 18
Patch Set 14 : Address dsinclair comments #Patch Set 15 : Make GetThreadLocalTracker a private static method #
Total comments: 4
Patch Set 16 : Move push/pop into TraceLog, add sanity checks to pseudo stack #
Total comments: 17
Patch Set 17 : Address Primiano "The Nit" Tucci's comments #
Dependent Patchsets: Messages
Total messages: 50 (7 generated)
ruuda@google.com changed reviewers: + primiano@chromium.org
picksi@google.com changed reviewers: + picksi@google.com
Some drive by comments! Please forgive stupid suggestions :) https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... File base/trace_event/pseudo_stack.cc (right): https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... base/trace_event/pseudo_stack.cc:34: if (ps && ps->generation() != subtle::NoBarrier_Load(&g_capture_generation)) { nit: Should this 'if' move inside the previous if? ... and drop the check for it being null (if it is guaranteed to have a value inside the if?) https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... base/trace_event/pseudo_stack.cc:48: bool PseudoStackController::capture_enabled_ = false; Should this be defined a the top of the file? https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... base/trace_event/pseudo_stack.cc:73: capture_enabled_ = false; Does this require the opposite of the AtomicIncrement (AtomicDecrement?) to keep the ref-counting happy?
https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... File base/trace_event/pseudo_stack.cc (right): https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... base/trace_event/pseudo_stack.cc:34: if (ps && ps->generation() != subtle::NoBarrier_Load(&g_capture_generation)) { On 2015/09/14 at 12:52:12, picksi wrote: > nit: Should this 'if' move inside the previous if? ... and drop the check for it being null (if it is guaranteed to have a value inside the if?) Yes. https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... base/trace_event/pseudo_stack.cc:48: bool PseudoStackController::capture_enabled_ = false; On 2015/09/14 at 12:52:12, picksi wrote: > Should this be defined a the top of the file? If that is the Chrome style, then yes. I put everything in PseudoStack first and then everything in PseudoStackController. https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... base/trace_event/pseudo_stack.cc:73: capture_enabled_ = false; On 2015/09/14 at 12:52:12, picksi wrote: > Does this require the opposite of the AtomicIncrement (AtomicDecrement?) to keep the ref-counting happy? No, the generation is not a refcount, it is a monotonically increasing counter. Different trace runs should have a different generation number to avoid mixing stack frames from unrelated traces.
https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... File base/trace_event/pseudo_stack.cc (right): https://codereview.chromium.org/1340013002/diff/20001/base/trace_event/pseudo... base/trace_event/pseudo_stack.cc:73: capture_enabled_ = false; OK, that makes sense. Is it worth adding _UID to the end of the variable name? Or adding a comment about what this does to prevent others making the same (incorrect) assumption that I did about ref-counting?
dsinclair@chromium.org changed reviewers: + dsinclair@chromium.org
Why do we need to output the stack if it's based on trace events? It seems like we should be able to output a single instant event for the heap dump, and then build the stack on the trace-viewer side based on the hierarchy of slices above the given instant events?
On 2015/09/14 13:28:31, dsinclair wrote: > Why do we need to output the stack if it's based on trace events? It seems like > we should be able to output a single instant event for the heap dump, and then > build the stack on the trace-viewer side based on the hierarchy of slices above > the given instant events? (Haven't looked at the CL yet) The main problem is that if the trace is long enough we might lose the slices, but the allocations created then will be still there. So we'd end up in a situation where we keep track of an allocation which happened early enough, but don't have the information to know what happened at that time. Let me have a look to this CL.
On 2015/09/14 13:28:31, dsinclair wrote: > Why do we need to output the stack if it's based on trace events? It seems like > we should be able to output a single instant event for the heap dump, and then > build the stack on the trace-viewer side based on the hierarchy of slices above > the given instant events? (Haven't looked at the CL yet) The main problem is that if the trace is long enough we might lose the slices, but the allocations created then will be still there. So we'd end up in a situation where we keep track of an allocation which happened early enough, but don't have the information to know what happened at that time. Let me have a look to this CL.
On 2015/09/14 13:39:06, Primiano Tucci wrote: > On 2015/09/14 13:28:31, dsinclair wrote: > > Why do we need to output the stack if it's based on trace events? It seems > like > > we should be able to output a single instant event for the heap dump, and then > > build the stack on the trace-viewer side based on the hierarchy of slices > above > > the given instant events? > > (Haven't looked at the CL yet) > > The main problem is that if the trace is long enough we might lose the slices, > but the allocations created then will be still there. > So we'd end up in a situation where we keep track of an allocation which > happened early enough, but don't have the information to know what happened at > that time. > > Let me have a look to this CL. So, the V8 Sampling profiler has the restriction that it can not be used in continuous trace mode which gets around them losing the code locations. There has been talk about making metadata events have their own buffer so they would be kept around (not that it helps for this as it isn't metadatastacks).
On 2015/09/14 13:39:06, Primiano Tucci wrote: > On 2015/09/14 13:28:31, dsinclair wrote: > > Why do we need to output the stack if it's based on trace events? It seems > like > > we should be able to output a single instant event for the heap dump, and then > > build the stack on the trace-viewer side based on the hierarchy of slices > above > > the given instant events? > > (Haven't looked at the CL yet) > > The main problem is that if the trace is long enough we might lose the slices, > but the allocations created then will be still there. > So we'd end up in a situation where we keep track of an allocation which > happened early enough, but don't have the information to know what happened at > that time. > > Let me have a look to this CL. Ok a major comment, before we get into nits & style: I don't think you have any need of a PseudoStackController here. I think that should be driven by the outside (very likely the MemoryDumpManager) and what you really need is just a boolean and a SetPseudoStackTrackingEnabled(bool) method that MDM will call when heap profiling is enabled/disabled. But before getting there let's check if we are all onboard with the plan of keeping the const char* of the slices.
> > Why do we need to output the stack if it's based on trace events? It seems like > > we should be able to output a single instant event for the heap dump, and then > > build the stack on the trace-viewer side based on the hierarchy of slices above > > the given instant events? > > The main problem is that if the trace is long enough we might lose the slices, but the allocations created then will be still there. > So we'd end up in a situation where we keep track of an allocation which happened early enough, but don't have the information to know what happened at that time. The main reason is that we cannot put every allocation into the trace json, the volume is much too large, so we have to group allocations by backtrace before dumping them. It might still be possible to cross-reference the allocation with the trace events at dump time if we keep a timestamp and a thread ID with every allocation, but I think it would be very complex to dig through all the events and reconstruct the stack that way. By capturing it real time you get this for free.
The controller has been removed. The design doc has been updated with trade offs regarding capturing the pseudo stack or reconstructing it later.
https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... File base/trace_event/pseudo_stack.cc (right): https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.cc:17: static int32_t g_capture_generation = 0; Should this be in an anonymous namespace? https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.cc:30: subtle::NoBarrier_AtomicIncrement(&g_capture_generation, 1); Instead of a generation number, why not just dump the stack at this point if it isnt' empty? https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.cc:50: delete ps; Why do you delete the stack and create a new one instead of just calling clear() on the vector? https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... File base/trace_event/pseudo_stack.h (right): https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.h:68: }; DISALLOW_COPY_AND_ASSIGN(PseudoStack); https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... base/trace_event/trace_event.h:212: #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ Can you please put the \'s back where they were to match the rest of the file? https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... base/trace_event/trace_event.h:218: trace_event_internal::kNoId, flags, trace_event_internal::kNoId, \ Put wrapping back as well, makes it easier to see the actual changes. https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... base/trace_event/trace_event.h:261: #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ What about these variants? https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... base/trace_event/trace_event.h:758: } nit: no {}'s on single line bodies.
Thanks for your comments Dan! This is still under construction, so please don’t spend too much time on it yet, things are going to change. After Nat’s remarks last Tuesday I think that instead of attaching a thread-local pseudo stack to every allocation, we should attach a thread-local piece of context, which includes the pseudo stack. There are two options here: 1. Keep |PseudoStack| as it is here, completely independent of heap profiling, and include it in the context when recording an allocation. Keep the rest of the context independently in TLS. 2. Keep all of the context including the pseudo stack in the same TLS slot. This does entangle the pseudo stack with heap profiling, but it has the advantage of requiring only a single TLS slot, and the lazy initialization / generation counter logic does not have to be duplicated. I discussed with Primiano just yet, at this point we think option 2 is the best way forward. https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... File base/trace_event/pseudo_stack.cc (right): https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.cc:17: static int32_t g_capture_generation = 0; On 2015/09/17 at 14:22:32, dsinclair wrote: > Should this be in an anonymous namespace? The static makes it visible only to the current translation unit. Is there a reason to prefer an anonymous namespace over static? https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.cc:30: subtle::NoBarrier_AtomicIncrement(&g_capture_generation, 1); On 2015/09/17 at 14:22:31, dsinclair wrote: > Instead of a generation number, why not just dump the stack at this point if it isnt' empty? Because capturing is enabled from one thread, but every thread has its own lazily initialized pseudo stack. We would have to somehow signal all threads to dump their stack. The generation counter allows every thread to check for itself whether a new session has started. https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.cc:50: delete ps; On 2015/09/17 at 14:22:32, dsinclair wrote: > Why do you delete the stack and create a new one instead of just calling clear() on the vector? Because it means that the generation can be an immutable property of the stack, and I like immutability. The underlying reason is that in my experience, re-using objects makes them hard to reason about. If somebody ever adds extra state to |PseudoStack| then deleting and constructing a new one will continue to do the right thing, whereas if you decide to re-use the old stack, you now have to replicate the constructor and destructor logic here. The compiler will not complain if you accidentally forget to to reset a piece of state. It does involve extra allocations, but initializing the pseudo stack is not a common operation (especially initializing it for the second time). Anyway, for such a simple class as |PseudoStack| it is mostly a matter of preference, I can change it if you like. https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... File base/trace_event/pseudo_stack.h (right): https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/pseud... base/trace_event/pseudo_stack.h:68: }; On 2015/09/17 at 14:22:32, dsinclair wrote: > DISALLOW_COPY_AND_ASSIGN(PseudoStack); Done. Why is it needed though? The default copy constructor will do the right thing here. https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... base/trace_event/trace_event.h:212: #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ On 2015/09/17 at 14:22:32, dsinclair wrote: > Can you please put the \'s back where they were to match the rest of the file? Done. Just know that git cl format did this. https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... base/trace_event/trace_event.h:218: trace_event_internal::kNoId, flags, trace_event_internal::kNoId, \ On 2015/09/17 at 14:22:32, dsinclair wrote: > Put wrapping back as well, makes it easier to see the actual changes. Done. https://codereview.chromium.org/1340013002/diff/100001/base/trace_event/trace... base/trace_event/trace_event.h:758: } On 2015/09/17 at 14:22:32, dsinclair wrote: > nit: no {}'s on single line bodies. Done.
Removing myself from the reviewers line for now. When you'd like me to look again please add me back.
dsinclair@chromium.org changed reviewers: - dsinclair@chromium.org
I moved the pseudo stack into a thread-local |AllocationContextManager|. (Not really satisfied with that name but I want to call a snapshot of its state |AllocationContext| ... suggestions are welcome.) Can you please take a look Primiano?
The design look good. I haven't looked at the test yet, will do soon. In the meantime, some nits here and there. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/BUILD.gn File base/trace_event/BUILD.gn (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/BUILD... base/trace_event/BUILD.gn:7: "allocation_context.cc", I'd probably rename this file (and classes) to give a stronger hint that this is about the heap profiler feature. Something like memory_profiler_allocation_context.cc (or something along this line) https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... File base/trace_event/allocation_context.cc (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:1: // Copyright (c) 2015 The Chromium Authors. All rights reserved. ditto (c) https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:15: static int32_t g_capture_generation = 0; Use StaticAtomicSequenceNumber here, so you reduce the amount of sublte:: usage See MemoryDumpManager Also, as a general pattern we not use "static ..." for globals, rather put them into an anonymous namespace https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:17: static ThreadLocalStorage::StaticSlot tls_alloc_ctx_mgr = TLS_INITIALIZER; As per code style, static globals should be named g_lower_with_under_; https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:26: void AllocationContextManager::set_capture_enabled(bool enabled) { add a // static above this, i.e. // static void Allocation.... https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:39: void DestructAllocationContextManager(void* alloc_ctx_mgr) { Add a comment specifying that this is only for the OnThreadExit handler. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:43: AllocationContextManager* AllocationContextManager::GetInstance() { Ditto, add // static https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:46: if (tls_alloc_ctx_mgr.initialized()) { Hmm I think this could be reworked to be a bit more readable: if (!initialized()) Initialize(Destruct....) AllocationContextManager* mgr = tls.get(); // will return 0 on the 1st call if (mgr && mgr->generation too old) { delete mgr mgr = nullptr } if (!mgr) { mgr = new ... tls.Set(mgr) } https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... File base/trace_event/allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:1: // Copyright (c) 2015 The Chromium Authors. All rights reserved. The new copyright header (>= 2014 IIRC) doesn't have the (c) anymore. Look at BUILD.gn above as an example. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:29: typedef std::vector<const char*>::const_reverse_iterator ConstIterator; should this be named just const_iterator (see reason below) https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:34: inline ConstIterator Top() const { return stack_.rbegin(); } should you just stick with begin() and end() names here, so you can use c++11 foreach? https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:56: static void set_capture_enabled(bool enabled); nit: SetCaptureEnabled. lower_with_under is only for inline methods. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:72: inline Stack& pseudo_stack() { return pseudo_stack_; } as a convention (see [1]) we allow either const reference or pointer. Returning a reference can make it not obvious that you are modifying the original object. ALso, I guess that here you really want const Stack& .... const { [1] https://google-styleguide.googlecode.com/svn/trunk/cppguide.html https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:74: inline void SetContextField(const char* key, const char* value) { I'd remove "Field" from the name (also below), the signature makes it clear that you are setting/clearing a field https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:100: std::map<const char*, const char*> context_; I'd probably use base/containers/small_map.h here, which for small maps (like the ones we're probably going to have here) is leaner and faster. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:220: trace_event_internal::UpdatePseudoStack(phase, name); \ Rename to MaybeUpdatePseudoStack, as that will happen only if the profiling is enableds https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:757: auto mgr = base::trace_event::AllocationContextManager::GetInstance(); mgr is a bit of a generic name. This should be allocation_context_manager. But at this point it's better to avoid the indirection and to a direct call from GetInstance() (and wrap it on two lines) same below https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:844: if (base::trace_event::AllocationContextManager::capture_enabled()) { In chromium we tend to prefer early return instead of nested ifs, they make the code generally more readable. i.e. if (!capture_enabled) return https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:849: if (phase == TRACE_EVENT_PHASE_END) s/if/else if/
https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... File base/trace_event/allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:29: typedef std::vector<const char*>::const_reverse_iterator ConstIterator; AH also I'd probably encapsulate the const char* into a struct StackFrame, so tomorrow would be easier to adapt for native stacks (which will take a void*, very likely)
ruuda@google.com changed reviewers: + dsinclair@chromium.org
+dsinclair, could you have a look now? https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/BUILD.gn File base/trace_event/BUILD.gn (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/BUILD... base/trace_event/BUILD.gn:7: "allocation_context.cc", On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > I'd probably rename this file (and classes) to give a stronger hint that this is about the heap profiler feature. > > Something like > memory_profiler_allocation_context.cc (or something along this line) Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... File base/trace_event/allocation_context.cc (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:1: // Copyright (c) 2015 The Chromium Authors. All rights reserved. On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > ditto (c) Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:15: static int32_t g_capture_generation = 0; On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > Use StaticAtomicSequenceNumber here, so you reduce the amount of sublte:: usage > See MemoryDumpManager > > Also, as a general pattern we not use "static ..." for globals, rather put them into an anonymous namespace |StaticAtomicSequenceNumber| does not have the ability to read without incrementing. Namespace done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:17: static ThreadLocalStorage::StaticSlot tls_alloc_ctx_mgr = TLS_INITIALIZER; On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > As per code style, static globals should be named g_lower_with_under_; Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:26: void AllocationContextManager::set_capture_enabled(bool enabled) { On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > add a // static above this, i.e. > > // static > void Allocation.... Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:39: void DestructAllocationContextManager(void* alloc_ctx_mgr) { On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > Add a comment specifying that this is only for the OnThreadExit handler. Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:43: AllocationContextManager* AllocationContextManager::GetInstance() { On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > Ditto, add // static Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:46: if (tls_alloc_ctx_mgr.initialized()) { On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > Hmm I think this could be reworked to be a bit more readable: > > if (!initialized()) > Initialize(Destruct....) > > AllocationContextManager* mgr = tls.get(); // will return 0 on the 1st call > > if (mgr && mgr->generation too old) { > delete mgr > mgr = nullptr > } > > if (!mgr) { > mgr = new ... > tls.Set(mgr) > } Done, but note that Simon requested that I merged the ifs in patchset 2 ... https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... File base/trace_event/allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:1: // Copyright (c) 2015 The Chromium Authors. All rights reserved. On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > The new copyright header (>= 2014 IIRC) doesn't have the (c) anymore. > Look at BUILD.gn above as an example. You are right. Fixed. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:29: typedef std::vector<const char*>::const_reverse_iterator ConstIterator; On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > should this be named just const_iterator (see reason below) The name of the iterator type is irrelevant to range-based for. But I can rename if you prefer STL style. > AH also I'd probably encapsulate the const char* into a struct StackFrame Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:34: inline ConstIterator Top() const { return stack_.rbegin(); } On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > should you just stick with begin() and end() names here, so you can use c++11 foreach? I don’t use the range-based for because I need to iterate over two ranges (source and destination) at once every time I use this. Because I do not need the begin/end for this reason, I think top/bottom is clearer since for a stack it is not clear which end is the beginning and which is the end. But if you prefer STL style I’ll rename. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:56: static void set_capture_enabled(bool enabled); On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > nit: SetCaptureEnabled. lower_with_under is only for inline methods. Done. Should it be |SetCaptureEnabled| for the setter but |capture_enabled| for the getter? https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:72: inline Stack& pseudo_stack() { return pseudo_stack_; } On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > as a convention (see [1]) we allow either const reference or pointer. > Returning a reference can make it not obvious that you are modifying the original object. > ALso, I guess that here you really want const Stack& .... const { > > > [1] https://google-styleguide.googlecode.com/svn/trunk/cppguide.html Done for the pointer. No, I need mutability to be able to push/pop. I could do a const overload but as it would not be used anywhere (snapshotting the pseudo stack uses the private member) I didn’t see the point. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:74: inline void SetContextField(const char* key, const char* value) { On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > I'd remove "Field" from the name (also below), the signature makes it clear that you are setting/clearing a field Naming is hard ... I would like to call a snapshot of the pseudo stack and these fields “context”, returned by the |GetContext| method, so I appended “Field” to avoid contextception. It would be confusing if |SetContext| and |GetContext| were not a getter/setter pair. I am open to suggestions. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:100: std::map<const char*, const char*> context_; On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > I'd probably use base/containers/small_map.h here, which for small maps (like the ones we're probably going to have here) is leaner and faster. Done. The header warns about increased code size though. Is this micro-optimising a non-bottleneck? https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:220: trace_event_internal::UpdatePseudoStack(phase, name); \ On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > Rename to MaybeUpdatePseudoStack, as that will happen only if the profiling is enableds Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:757: auto mgr = base::trace_event::AllocationContextManager::GetInstance(); On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > mgr is a bit of a generic name. This should be allocation_context_manager. But at this point it's better to avoid the indirection and to a direct call from GetInstance() (and wrap it on two lines) > same below Yeah I split that because I thought the line wrap was ugly, if it’s going to overflow anyway then one line is better. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:844: if (base::trace_event::AllocationContextManager::capture_enabled()) { On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > In chromium we tend to prefer early return instead of nested ifs, they make the code generally more readable. > > i.e. > if (!capture_enabled) > return Done. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/trace... base/trace_event/trace_event.h:849: if (phase == TRACE_EVENT_PHASE_END) On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > s/if/else if/ Done. The compiler will emit the same code anyway, right?
Some extra comments on my side. dsinclair, maybe let's first have our VC before you get to this. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... File base/trace_event/allocation_context.cc (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.cc:15: static int32_t g_capture_generation = 0; > |StaticAtomicSequenceNumber| does not have the ability to read without > incrementing. Namespace done. Well, of course (would defeat atomicity otherwise). What I meant was: use StaticAotmicSequenceNumber for the generation + a global to keep the current generation number. https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... File base/trace_event/allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:56: static void set_capture_enabled(bool enabled); On 2015/09/21 10:10:05, Ruud van Asseldonk wrote: > On 2015/09/18 at 16:10:01, Primiano Tucci wrote: > > nit: SetCaptureEnabled. lower_with_under is only for inline methods. > > Done. Should it be |SetCaptureEnabled| for the setter but |capture_enabled| for > the getter? You will hate this answer but... yes :) https://codereview.chromium.org/1340013002/diff/180001/base/trace_event/alloc... base/trace_event/allocation_context.h:100: std::map<const char*, const char*> context_; On 2015/09/21 10:10:05, Ruud van Asseldonk wrote: > On 2015/09/18 at 16:10:00, Primiano Tucci wrote: > > I'd probably use base/containers/small_map.h here, which for small maps (like > the ones we're probably going to have here) is leaner and faster. > > Done. The header warns about increased code size though. Is this > micro-optimising a non-bottleneck? Well, this is going to be in the middle of each invidivual allocation (when tracing is enabled), so not sure I'd call is a "non-bottleneck" https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.cc (right): https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:33: if (!!subtle::NoBarrier_Load(&capture_enabled_) == enabled) Instead of re-using subtle just use capture_enabled() here. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:38: subtle::NoBarrier_Store(&capture_enabled_, enabled); You want to set this after the generation, right? https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:42: subtle::NoBarrier_AtomicIncrement(&g_capture_generation, 1); plz use the StaticAtomicCounter here. There is wayy too much sublte-ty in this cc file :) https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:63: mgr->generation_ != subtle::NoBarrier_Load(&g_capture_generation)) { Keep g_capture_generation as a plain int32 and remove the subtle here https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:71: g_tls_alloc_ctx_mgr.Set(static_cast<void*>(mgr)); uh is this cast to void* required? https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:8: #include <map> you can remove this include at this point https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:14: #include "base/trace_event/trace_log.h" Just checking, what do you need this for? https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:30: class BASE_EXPORT Stack { Stack feels a bit too generic as a name. Should this be something like {AllocationStackTrace, AllocationCallStack, CallStack}? https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:37: inline ConstIterator Top() const { return stack_.rbegin(); } nit: lowercase T, same below, as these are trivial getters https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:56: class BASE_EXPORT AllocationContextManager { Please add a few lines comment explaining what this is for (And the generation logic). https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:65: // not enabled, so issue no memory barrier. nit: don't issue any memory barrier https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:73: // Returns the pseudo stack where frames are |TRACE_EVENT| names. These macros I'd keep this a bit more generic and say: Returns the pseudo stack, a frame of TRACE_EVENT(s). https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:83: if (pos != context_.end()) isn't all this == to context_.erase(key) ? https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/trace... base/trace_event/trace_event.h:756: if (base::trace_event::AllocationContextManager::capture_enabled()) Let's rename Manager -> Tracker https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/trace... base/trace_event/trace_event.h:757: base::trace_event::AllocationContextManager::GetInstance() I think this should just be a static AllocationContextTracker::PopPseudoStackFrame() or similar same below
Please don’t pay too much attention to the tests yet, these will change completely in my follow-up CL. My initial idea was to have the pseudo stack logic independent of snapshotting the context, so I have tests that check that the pseudo stack is constructed properly, and in my follow-up CL I have tests for snapshotting it. Now that Push/Pop are statics that don’t expose the stack itself, only snapshotting can be tested (without exposing implementation to tests), so I will change that in my next CL. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.cc (right): https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:33: if (!!subtle::NoBarrier_Load(&capture_enabled_) == enabled) On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > Instead of re-using subtle just use capture_enabled() here. Done. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:38: subtle::NoBarrier_Store(&capture_enabled_, enabled); On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > You want to set this after the generation, right? Strictly speaking, yes. But both are nobarrier, so the compiler and CPU can decide to swap them either way. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:42: subtle::NoBarrier_AtomicIncrement(&g_capture_generation, 1); On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > plz use the StaticAtomicCounter here. There is wayy too much sublte-ty in this cc file :) Agreed offline to remove the generation altogether because we never want to enable in-flight anyway, so leftovers are not an issue. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:63: mgr->generation_ != subtle::NoBarrier_Load(&g_capture_generation)) { On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > Keep g_capture_generation as a plain int32 and remove the subtle here Not relevant any more. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.cc:71: g_tls_alloc_ctx_mgr.Set(static_cast<void*>(mgr)); On 2015/09/22 at 10:15:00, Primiano Tucci wrote: > uh is this cast to void* required? The TLS slot stores |void*|, but apparently C++ has implicit conversion from |T*| to |void*| so the cast is not required. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:8: #include <map> On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > you can remove this include at this point Done. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:14: #include "base/trace_event/trace_log.h" On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > Just checking, what do you need this for? Nothing. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:30: class BASE_EXPORT Stack { On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > Stack feels a bit too generic as a name. Should this be something like {AllocationStackTrace, AllocationCallStack, CallStack}? Done. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:37: inline ConstIterator Top() const { return stack_.rbegin(); } On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > nit: lowercase T, same below, as these are trivial getters Done. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:56: class BASE_EXPORT AllocationContextManager { On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > Please add a few lines comment explaining what this is for (And the generation logic). Done. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:65: // not enabled, so issue no memory barrier. On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > nit: don't issue any memory barrier Done. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:73: // Returns the pseudo stack where frames are |TRACE_EVENT| names. These macros On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > I'd keep this a bit more generic and say: > Returns the pseudo stack, a frame of TRACE_EVENT(s). Done. And then made irrelevant because the stack will not be exposed. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:83: if (pos != context_.end()) On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > isn't all this == to context_.erase(key) ? Yep. Somehow I was under the illusion that |erase(key)| was a C++11 feature. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/trace... base/trace_event/trace_event.h:756: if (base::trace_event::AllocationContextManager::capture_enabled()) On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > Let's rename Manager -> Tracker Done. https://codereview.chromium.org/1340013002/diff/200001/base/trace_event/trace... base/trace_event/trace_event.h:757: base::trace_event::AllocationContextManager::GetInstance() On 2015/09/22 at 10:15:01, Primiano Tucci wrote: > I think this should just be a static > AllocationContextTracker::PopPseudoStackFrame() or similar > > same below Done.
Makes sense, +dsinclair (if you prefer you can defer the test to later when this will do more stuff)
https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:27: typedef std::vector<StackFrame>::const_reverse_iterator ConstIterator; Should this be ConstReverseIterator to make it clear? https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:36: inline void Pop() { nit: Should these be push/pop to be consistent with top/bottom? https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:57: friend AllocationContextTracker* GetThreadLocalTracker(); Why is this a friend function and not just in an anonymous namespace in the cpp file? https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:89: ~AllocationContextTracker(); Move this below the GetPseudoStack so all the static methods are grouped. https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:92: static AllocationStack* GetPseudoStack(); nit: s/GetPseudoStack/GetPseudoStackForTesting https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... base/trace_event/trace_event.h:261: #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ MaybeUpdatePsuedoStack? https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... base/trace_event/trace_event.h:278: #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ MaybeUpdatePseudOStack? https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... base/trace_event/trace_event.h:719: return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( Should the MaybeStorePseudOStack happen in here? This is what the macros call into. Would just need to update this method as the others call this one.
https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:27: typedef std::vector<StackFrame>::const_reverse_iterator ConstIterator; On 2015/09/22 at 17:05:21, dsinclair wrote: > Should this be ConstReverseIterator to make it clear? I don't think that would make anything clearer. I deliberately called the iterator returning functions |top| and |bottom|, because it is not clear whether the top is the begin or end. But now I realise that without the iterator direction this is still ambiguous. So perhaps |ConstDownIterator| would be a better name? Or should I just go full-STL at this point and call them begin/end/ConstIterator? (That iterating the stack happens to iterate the vector backwards is an implementation detail.) https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:36: inline void Pop() { On 2015/09/22 at 17:05:21, dsinclair wrote: > nit: Should these be push/pop to be consistent with top/bottom? Done. https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:57: friend AllocationContextTracker* GetThreadLocalTracker(); On 2015/09/22 at 17:05:21, dsinclair wrote: > Why is this a friend function and not just in an anonymous namespace in the cpp file? Because it has to construct the |AllocationContextTracker| if there is none in TLS, but I made the constructor private. Would it be better to make the constructor public? Then |GetThreadLocalTracker| does not need to be a friend. https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:89: ~AllocationContextTracker(); On 2015/09/22 at 17:05:21, dsinclair wrote: > Move this below the GetPseudoStack so all the static methods are grouped. Done. https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:92: static AllocationStack* GetPseudoStack(); On 2015/09/22 at 17:05:21, dsinclair wrote: > nit: s/GetPseudoStack/GetPseudoStackForTesting Done. https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... base/trace_event/trace_event.h:261: #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ On 2015/09/22 at 17:05:21, dsinclair wrote: > MaybeUpdatePsuedoStack? Done. https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... base/trace_event/trace_event.h:278: #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ On 2015/09/22 at 17:05:21, dsinclair wrote: > MaybeUpdatePseudOStack? Done. https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... base/trace_event/trace_event.h:719: return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( On 2015/09/22 at 17:05:21, dsinclair wrote: > Should the MaybeStorePseudOStack happen in here? This is what the macros call into. Would just need to update this method as the others call this one. Do you propose to remove the calls from the other macros and have one here? This location is not hit in the tests, am I doing something wrong? I got a bit lost chasing all the macros and calls, but as far as I could see there is no code path that is shared among |TRACE_EVENT*| and |TRACE_EVENT_BEGIN*| / |TRACE_EVENT_END*| where the name and whether it is the beginning or end of the event is known. Is that correct?
https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:57: friend AllocationContextTracker* GetThreadLocalTracker(); On 2015/09/23 09:39:03, Ruud van Asseldonk wrote: > On 2015/09/22 at 17:05:21, dsinclair wrote: > > Why is this a friend function and not just in an anonymous namespace in the > cpp file? > > Because it has to construct the |AllocationContextTracker| if there is none in > TLS, but I made the constructor private. Would it be better to make the > constructor public? Then |GetThreadLocalTracker| does not need to be a friend. So why not make GetThreadLocalTracker a static method of AllocationContextTracker? Can get rid of the friend and I believe can still access the constructor? https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/240001/base/trace_event/trace... base/trace_event/trace_event.h:719: return TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( On 2015/09/23 09:39:03, Ruud van Asseldonk wrote: > On 2015/09/22 at 17:05:21, dsinclair wrote: > > Should the MaybeStorePseudOStack happen in here? This is what the macros call > into. Would just need to update this method as the others call this one. > > Do you propose to remove the calls from the other macros and have one here? This > location is not hit in the tests, am I doing something wrong? I got a bit lost > chasing all the macros and calls, but as far as I could see there is no code > path that is shared among |TRACE_EVENT*| and |TRACE_EVENT_BEGIN*| / > |TRACE_EVENT_END*| where the name and whether it is the beginning or end of the > event is known. Is that correct? Yes, removing from the macros and putting here was my suggestion. What do you mean it isn't hit in tests? Which tests, your local testing? The macros above call trace_event_internal::AddTraceEventWithThreadIdAndTimestamp (or other variants but those call this one) so this should be getting executed?
On 2015/09/23 at 19:35:21, dsinclair wrote: > So why not make GetThreadLocalTracker a static method of AllocationContextTracker? Can get rid of the friend and I believe can still access the constructor? Good point, done. > Yes, removing from the macros and putting here was my suggestion. What do you mean it isn't hit in tests? Which tests, your local testing? > > The macros above call trace_event_internal::AddTraceEventWithThreadIdAndTimestamp (or other variants but those call this one) so this should be getting executed? It is never hit in the tests in base/trace_event/memory_profiler_allocation_context_unittest.cc. The function on |trace_event_internal::AddTraceEventWithThreadIdAndTimestamp| with 9 arguments (without the templates) is hit. There still are nine overloads of |trace_event_internal::AddTraceEventWithThreadIdAndTimestamp| which call |TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP|, but modifying that macro is not an option because the arguments are not part of the macro. It redirects to |TraceLog::AddTraceEventWithThreadIdAndTimestamp|, so would it be better to put the push/pop for the begin/end macros in |TraceLog| then?
On 2015/09/24 10:19:00, Ruud van Asseldonk wrote: > On 2015/09/23 at 19:35:21, dsinclair wrote: > > So why not make GetThreadLocalTracker a static method of > AllocationContextTracker? Can get rid of the friend and I believe can still > access the constructor? > > Good point, done. > > > > Yes, removing from the macros and putting here was my suggestion. What do you > mean it isn't hit in tests? Which tests, your local testing? > > > > The macros above call > trace_event_internal::AddTraceEventWithThreadIdAndTimestamp (or other variants > but those call this one) so this should be getting executed? > > It is never hit in the tests in > base/trace_event/memory_profiler_allocation_context_unittest.cc. The function on > |trace_event_internal::AddTraceEventWithThreadIdAndTimestamp| with 9 arguments > (without the templates) is hit. There still are nine overloads of > |trace_event_internal::AddTraceEventWithThreadIdAndTimestamp| which call > |TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP|, but modifying > that macro is not an option because the arguments are not part of the macro. It > redirects to |TraceLog::AddTraceEventWithThreadIdAndTimestamp|, so would it be > better to put the push/pop for the begin/end macros in |TraceLog| then? I don't think that would do what you want in the case of the scoped macro. So, I guess leaving it in the macros is the best place. lgtm.
https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:17: // The allocation context is attached to every allocation when heap profiling I'd probably reword this a bit. By reading it feels like you are adding stuff to each allocated memory chunk. The reality is that you are keeping track "sideways", without attaching anything to the actual allocation. I'd probably say. When heap profiling is enabled, tracing keeps track of the allocation context for each allocation intercepted. The context is generated... https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/trace... base/trace_event/trace_event.h:220: trace_event_internal::MaybeUpdatePseudoStack(phase, name); \ My main concerns here are: 1) this is a bit fragile: if somebody creates yet another copy of this macro and doesn't pick the MaybeUpdate you are screwed. 2) This will not work with embedders (blink, skia) who have their own copies of this header. And I think you don't want to get into exporting the Push/Pop API and changing all those codebases. My proposal is to do the PushPop only in TraceLog (which lives only in base, and not in the embedder) specifically in AddTraceEventWithThreadIdAndTimestamp, which seems the leaf-most function being called by everything. The only catch is that for scoped event you have to do the pop in TraceLog::UpdateTraceEventDuration, as you don't have BEGIN/END phases there, but only one phase + the update duration
On 2015/09/24 14:45:20, Primiano Tucci wrote: > https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/memor... > File base/trace_event/memory_profiler_allocation_context.h (right): > > https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/memor... > base/trace_event/memory_profiler_allocation_context.h:17: // The allocation > context is attached to every allocation when heap profiling > I'd probably reword this a bit. By reading it feels like you are adding stuff to > each allocated memory chunk. > The reality is that you are keeping track "sideways", without attaching anything > to the actual allocation. > I'd probably say. > > When heap profiling is enabled, tracing keeps track of the allocation context > for each allocation intercepted. The context is generated... > > https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/trace... > File base/trace_event/trace_event.h (right): > > https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/trace... > base/trace_event/trace_event.h:220: > trace_event_internal::MaybeUpdatePseudoStack(phase, name); \ > My main concerns here are: > 1) this is a bit fragile: if somebody creates yet another copy of this macro and > doesn't pick the MaybeUpdate you are screwed. > > 2) This will not work with embedders (blink, skia) who have their own copies of > this header. And I think you don't want to get into exporting the Push/Pop API > and changing all those codebases. > > My proposal is to do the PushPop only in TraceLog (which lives only in base, and > not in the embedder) specifically in AddTraceEventWithThreadIdAndTimestamp, > which seems the leaf-most function being called by everything. > > The only catch is that for scoped event you have to do the pop in > TraceLog::UpdateTraceEventDuration, as you don't have BEGIN/END phases there, > but only one phase + the update duration When do you do the push? If it's in the scoper, you're going to have some weird interaction as the scoper will push in the constructor, then pop in update duration, then we push and pop immediately in the AddTraceEvent. Is that fine? Seems a bit weird and a bit of extra work. I guess the AddTraceEvent code could skip the X phase events?
> When do you do the push? If it's in the scoper, you're going to have some
weird
> interaction as the scoper will push in the constructor, then pop in update
> duration, then we push and pop immediately in the AddTraceEvent.
Nope, for the scoped you'll have to do the push in
TraceLog::AddTraceEventWithThreadIdAndTimestamp(TRACE_EVENT_PHASE_COMPLETE)
Essentially, draft:
TraceLog::AddTraceEventWithThreadIdAndTimestamp
{
case TRACE_EVENT_PHASE_BEGIN -> Push()
case TRACE_EVENT_PHASE_COMPLETE -> Push()
case TRACE_EVENT_PHASE_END -> Pop()
}
TraceLog::UpdateTraceEventDuration
{
if event.phase == TRACE_EVENT_PHASE_COMPLETE -> Pop()
}
and you could have DCHECKS on events name to check that the push/pop pairs on
the stack are consistent.
> Is that fine? Seems a bit weird and a bit of extra work. I guess the
> AddTraceEvent code could skip the X phase events?
On 2015/09/24 14:51:37, Primiano Tucci wrote:
> > When do you do the push? If it's in the scoper, you're going to have some
> weird
> > interaction as the scoper will push in the constructor, then pop in update
> > duration, then we push and pop immediately in the AddTraceEvent.
> Nope, for the scoped you'll have to do the push in
> TraceLog::AddTraceEventWithThreadIdAndTimestamp(TRACE_EVENT_PHASE_COMPLETE)
> Essentially, draft:
>
> TraceLog::AddTraceEventWithThreadIdAndTimestamp
> {
> case TRACE_EVENT_PHASE_BEGIN -> Push()
> case TRACE_EVENT_PHASE_COMPLETE -> Push()
> case TRACE_EVENT_PHASE_END -> Pop()
> }
>
> TraceLog::UpdateTraceEventDuration
> {
> if event.phase == TRACE_EVENT_PHASE_COMPLETE -> Pop()
> }
>
> and you could have DCHECKS on events name to check that the push/pop pairs on
> the stack are consistent.
>
> > Is that fine? Seems a bit weird and a bit of extra work. I guess the
> > AddTraceEvent code could skip the X phase events?
Ah, we changed the scoped tracer to push and then update instead of pushing at
the end of the event. So, the one concern is that your push/pop's are out of
order. The complete push is popped by the end instead of the complete finishing.
If I understand correctly, the begin/end can just be intercepted in |TraceLog::AddTraceEventWithThreadIdAndTimestamp|. The beginning of a scoped event can also be intercepted there, but its end must be intercepted at |TraceLog::UpdateTraceEventDuration|. So the question is, is |UpdateTraceEventDuration| called exactly once for every scoped trace event? This appears to be the case.
> Ah, we changed the scoped tracer to push and then update instead of pushing at
> the end of the event. So, the one concern is that your push/pop's are out of
> order. The complete push is popped by the end instead of the complete
finishing.
Uhm not sure I follow the out-of-order thing.
If I am reading the code correctly, when you have a scoped event that expands
into:
-create a ScopedTracer object
- if(category_enabled)
- AddTraceEvent(PHASE_COMPLETE)
- Initialize scoped tracer
When the scoped tracer goes out of scope
~ScopedTracer() {
if (was_nitialized)
UpdateDuration(...)
}
So you should still see the push (of PHASE_COMPLETE) first and then the pop (on
updateduration), no?
On 2015/09/24 15:05:21, Primiano Tucci wrote:
> > Ah, we changed the scoped tracer to push and then update instead of pushing
at
> > the end of the event. So, the one concern is that your push/pop's are out of
> > order. The complete push is popped by the end instead of the complete
> finishing.
>
> Uhm not sure I follow the out-of-order thing.
> If I am reading the code correctly, when you have a scoped event that expands
> into:
> -create a ScopedTracer object
> - if(category_enabled)
> - AddTraceEvent(PHASE_COMPLETE)
> - Initialize scoped tracer
>
> When the scoped tracer goes out of scope
> ~ScopedTracer() {
> if (was_nitialized)
> UpdateDuration(...)
> }
>
>
> So you should still see the push (of PHASE_COMPLETE) first and then the pop
(on
> updateduration), no?
Sorry, that was me mis-reading what you were saying in #35. Didn't notice the
case in front though that was what you'd said.
https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:17: // The allocation context is attached to every allocation when heap profiling On 2015/09/24 at 14:45:20, Primiano Tucci wrote: > I'd probably reword this a bit. By reading it feels like you are adding stuff to each allocated memory chunk. > The reality is that you are keeping track "sideways", without attaching anything to the actual allocation. > I'd probably say. > > When heap profiling is enabled, tracing keeps track of the allocation context for each allocation intercepted. The context is generated... Done. https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1340013002/diff/280001/base/trace_event/trace... base/trace_event/trace_event.h:220: trace_event_internal::MaybeUpdatePseudoStack(phase, name); \ On 2015/09/24 at 14:45:20, Primiano Tucci wrote: > My main concerns here are: > 1) this is a bit fragile: if somebody creates yet another copy of this macro and doesn't pick the MaybeUpdate you are screwed. > > 2) This will not work with embedders (blink, skia) who have their own copies of this header. And I think you don't want to get into exporting the Push/Pop API and changing all those codebases. > > My proposal is to do the PushPop only in TraceLog (which lives only in base, and not in the embedder) specifically in AddTraceEventWithThreadIdAndTimestamp, which seems the leaf-most function being called by everything. > > The only catch is that for scoped event you have to do the pop in TraceLog::UpdateTraceEventDuration, as you don't have BEGIN/END phases there, but only one phase + the update duration Done.
Thanks for the patience. LGTM with some final nits. Just wait for dsinclair to confirm. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:22: typedef const char* StackFrame; using StackFrame = const char *; https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:39: DCHECK(stack_.size() < 128); DCHECK_LT(stack_.size(), 128) https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context_unittest.cc (right): https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:14: void AssertFramesEqual(StackFrame lhs, StackFrame rhs) { you can remove this function and just use ASSERT_STREQ (which does a deep str compare) https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:28: void AssertPseudoStackEquals(StackFrame(&expected_stack)[N]) { +const? (otherwise there is the risk that plebeians might understand this) :P https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:81: AssertPseudoStackEquals(frame_dc); maybe just AssertPseudoStackEquals({d, c}); without the extra level of indirection? same below https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:169: you probably want also a test that covers mixed cases (TRACE_EVENT0 + BEGIN/END pairs) https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/trace... File base/trace_event/trace_log.cc (right): https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/trace... base/trace_event/trace_log.cc:1325: if (phase == TRACE_EVENT_PHASE_BEGIN || phase == TRACE_EVENT_PHASE_COMPLETE) plz add a comment saying that for PHASE_COMPLETE "see UpdateTraceEvent... for the matching pop" https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/trace... base/trace_event/trace_log.cc:1438: // Popping here works -- assuming that the duration is updated exactly this comment is redundant and a bit misleading. Everybody assumes that when you land code you believe it works :)
Still lg to me with primianos issues fixed.
https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context.h (right): https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:22: typedef const char* StackFrame; On 2015/09/24 at 15:58:34, Primiano Tucci wrote: > using StackFrame = const char *; Done. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context.h:39: DCHECK(stack_.size() < 128); On 2015/09/24 at 15:58:34, Primiano Tucci wrote: > DCHECK_LT(stack_.size(), 128) Done. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context_unittest.cc (right): https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:14: void AssertFramesEqual(StackFrame lhs, StackFrame rhs) { On 2015/09/24 at 15:58:35, Primiano Tucci wrote: > you can remove this function and just use ASSERT_STREQ (which does a deep str compare) Done. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:28: void AssertPseudoStackEquals(StackFrame(&expected_stack)[N]) { On 2015/09/24 at 15:58:35, Primiano Tucci wrote: > +const? (otherwise there is the risk that plebeians might understand this) :P Of course. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:81: AssertPseudoStackEquals(frame_dc); On 2015/09/24 at 15:58:34, Primiano Tucci wrote: > maybe just AssertPseudoStackEquals({d, c}); > without the extra level of indirection? same below Then the compiler cannot infer the int template argument so it has to be |AssertPseudoStackEquals<2>({d, c})| which is more obscure in my opinion. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:169: On 2015/09/24 at 15:58:35, Primiano Tucci wrote: > you probably want also a test that covers mixed cases (TRACE_EVENT0 + BEGIN/END pairs) Done. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/trace... File base/trace_event/trace_log.cc (right): https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/trace... base/trace_event/trace_log.cc:1325: if (phase == TRACE_EVENT_PHASE_BEGIN || phase == TRACE_EVENT_PHASE_COMPLETE) On 2015/09/24 at 15:58:35, Primiano Tucci wrote: > plz add a comment saying that for PHASE_COMPLETE "see UpdateTraceEvent... for the matching pop" Done. https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/trace... base/trace_event/trace_log.cc:1438: // Popping here works -- assuming that the duration is updated exactly On 2015/09/24 at 15:58:35, Primiano Tucci wrote: > this comment is redundant and a bit misleading. Everybody assumes that when you land code you believe it works :) Removed, replaced with comment about matching push. What I meant to say was “Assuming that the duration is updated exactly once, this is the correct place to do the pop.”
Great. ship it... once the win bots are happy :) https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... File base/trace_event/memory_profiler_allocation_context_unittest.cc (right): https://codereview.chromium.org/1340013002/diff/300001/base/trace_event/memor... base/trace_event/memory_profiler_allocation_context_unittest.cc:81: AssertPseudoStackEquals(frame_dc); On 2015/09/24 17:05:40, Ruud van Asseldonk wrote: > On 2015/09/24 at 15:58:34, Primiano Tucci wrote: > > maybe just AssertPseudoStackEquals({d, c}); > > without the extra level of indirection? same below > > Then the compiler cannot infer the int template argument so it has to be > |AssertPseudoStackEquals<2>({d, c})| which is more obscure in my opinion. oh right, nevermind then. sgtm
The CQ bit was checked by ruuda@google.com
The patchset sent to the CQ was uploaded after l-g-t-m from dsinclair@chromium.org, primiano@chromium.org Link to the patchset: https://codereview.chromium.org/1340013002/#ps320001 (title: "Address Primiano "The Nit" Tucci's comments")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1340013002/320001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1340013002/320001
Message was sent while issue was closed.
Committed patchset #17 (id:320001)
Message was sent while issue was closed.
Patchset 17 (id:??) landed as https://crrev.com/abff8221c8d35916a8d7e12845ba61bc5c48aff8 Cr-Commit-Position: refs/heads/master@{#350799}
Message was sent while issue was closed.
A revert of this CL (patchset #17 id:320001) has been created in https://codereview.chromium.org/1370693003/ by caitkp@chromium.org. The reason for reverting is: Consistent test failures on Win7 dbg http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%28... AllocationContextTest.PseudoStackBeginEndTrace (run #1): [ RUN ] AllocationContextTest.PseudoStackBeginEndTrace [3804:3148:0925/051951:43082047:FATAL:memory_profiler_allocation_context.cc(61)] Check failed: frame == *tracker->pseudo_stack_.top() (Donut vs. Donut) Backtrace: base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x1009A3A1+520392] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x100F1EEB+879634] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x102A1258+2645887] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x10300F01+3038248] base::trace_event::AllocationContextTest_PseudoStackScopedTrace_Test::`scalar deleting destructor' [0x00CA30CE+446] base::trace_event::AllocationContextTest_PseudoStackScopedTrace_Test::`scalar deleting destructor' [0x00CA2FDB+203] base::trace_event::AllocationContextTest_PseudoStackBeginEndTrace_Test::TestBody [0x00CA3913+467] testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void> [0x00DB1357+55] testing::Test::Run [0x00DCEFFE+174] testing::TestInfo::Run [0x00DCF29D+221] testing::TestCase::Run [0x00DCF13F+239] testing::internal::UnitTestImpl::RunAllTests [0x00DCF776+726] testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool> [0x00DB1447+55] testing::UnitTest::Run [0x00DCF42B+267] RUN_ALL_TESTS [0x00E05E6F+15] base::TestSuite::Run [0x00E0602B+171] `anonymous namespace'::RunTestSuite [0x00DF8367+55] base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>::Run [0x00DF8306+54] base::internal::InvokeHelper<0,int,base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>,base::internal::TypeList<int const &,char * * const &> >::MakeItSo [0x00DF8245+37] base::internal::Invoker<base::IndexSequence<0,1>,base::internal::BindState<base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>,int __cdecl(int,char * *),base::internal::TypeList<int,char * *> >,base::internal::TypeList<base::internal::UnwrapTrai [0x00DF82BF+111] base::Callback<int __cdecl(void)>::Run [0x004FCC9F+47] base::`anonymous namespace'::LaunchUnitTestsInternal [0x00DFF8C1+497] base::LaunchUnitTests [0x00DFF61D+109] main [0x00DF8410+80] __tmainCRTStartup [0x00DF6369+409] (f:\ddctools\crt\crtw32\dllstuff\crtexe.c:626) mainCRTStartup [0x00DF64AD+13] (f:\ddctools\crt\crtw32\dllstuff\crtexe.c:466) BaseThreadInitThunk [0x7638337A+18] RtlInitializeExceptionChain [0x76EC92B2+99] RtlInitializeExceptionChain [0x76EC9285+54] AllocationContextTest.PseudoStackBeginEndTrace (run #2): [ RUN ] AllocationContextTest.PseudoStackBeginEndTrace [2724:1644:0925/051955:43086742:FATAL:memory_profiler_allocation_context.cc(61)] Check failed: frame == *tracker->pseudo_stack_.top() (Donut vs. Donut) Backtrace: base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x1009A3A1+520392] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x100F1EEB+879634] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x102A1258+2645887] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x10300F01+3038248] base::trace_event::AllocationContextTest_PseudoStackScopedTrace_Test::`scalar deleting destructor' [0x00CA30CE+446] base::trace_event::AllocationContextTest_PseudoStackScopedTrace_Test::`scalar deleting destructor' [0x00CA2FDB+203] base::trace_event::AllocationContextTest_PseudoStackBeginEndTrace_Test::TestBody [0x00CA3913+467] testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void> [0x00DB1357+55] testing::Test::Run [0x00DCEFFE+174] testing::TestInfo::Run [0x00DCF29D+221] testing::TestCase::Run [0x00DCF13F+239] testing::internal::UnitTestImpl::RunAllTests [0x00DCF776+726] testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool> [0x00DB1447+55] testing::UnitTest::Run [0x00DCF42B+267] RUN_ALL_TESTS [0x00E05E6F+15] base::TestSuite::Run [0x00E0602B+171] `anonymous namespace'::RunTestSuite [0x00DF8367+55] base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>::Run [0x00DF8306+54] base::internal::InvokeHelper<0,int,base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>,base::internal::TypeList<int const &,char * * const &> >::MakeItSo [0x00DF8245+37] base::internal::Invoker<base::IndexSequence<0,1>,base::internal::BindState<base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>,int __cdecl(int,char * *),base::internal::TypeList<int,char * *> >,base::internal::TypeList<base::internal::UnwrapTrai [0x00DF82BF+111] base::Callback<int __cdecl(void)>::Run [0x004FCC9F+47] base::`anonymous namespace'::LaunchUnitTestsInternal [0x00DFF8C1+497] base::LaunchUnitTests [0x00DFF61D+109] main [0x00DF8410+80] __tmainCRTStartup [0x00DF6369+409] (f:\ddctools\crt\crtw32\dllstuff\crtexe.c:626) mainCRTStartup [0x00DF64AD+13] (f:\ddctools\crt\crtw32\dllstuff\crtexe.c:466) BaseThreadInitThunk [0x7638337A+18] RtlInitializeExceptionChain [0x76EC92B2+99] RtlInitializeExceptionChain [0x76EC9285+54] AllocationContextTest.PseudoStackBeginEndTrace (run #3): [ RUN ] AllocationContextTest.PseudoStackBeginEndTrace [4072:3120:0925/051957:43088162:FATAL:memory_profiler_allocation_context.cc(61)] Check failed: frame == *tracker->pseudo_stack_.top() (Donut vs. Donut) Backtrace: base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x1009A3A1+520392] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x100F1EEB+879634] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x102A1258+2645887] base::time_internal::TimeBase<base::ThreadTicks>::ToInternalValue [0x10300F01+3038248] base::trace_event::AllocationContextTest_PseudoStackScopedTrace_Test::`scalar deleting destructor' [0x00CA30CE+446] base::trace_event::AllocationContextTest_PseudoStackScopedTrace_Test::`scalar deleting destructor' [0x00CA2FDB+203] base::trace_event::AllocationContextTest_PseudoStackBeginEndTrace_Test::TestBody [0x00CA3913+467] testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void> [0x00DB1357+55] testing::Test::Run [0x00DCEFFE+174] testing::TestInfo::Run [0x00DCF29D+221] testing::TestCase::Run [0x00DCF13F+239] testing::internal::UnitTestImpl::RunAllTests [0x00DCF776+726] testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool> [0x00DB1447+55] testing::UnitTest::Run [0x00DCF42B+267] RUN_ALL_TESTS [0x00E05E6F+15] base::TestSuite::Run [0x00E0602B+171] `anonymous namespace'::RunTestSuite [0x00DF8367+55] base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>::Run [0x00DF8306+54] base::internal::InvokeHelper<0,int,base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>,base::internal::TypeList<int const &,char * * const &> >::MakeItSo [0x00DF8245+37] base::internal::Invoker<base::IndexSequence<0,1>,base::internal::BindState<base::internal::RunnableAdapter<int (__cdecl*)(int,char * *)>,int __cdecl(int,char * *),base::internal::TypeList<int,char * *> >,base::internal::TypeList<base::internal::UnwrapTrai [0x00DF82BF+111] base::Callback<int __cdecl(void)>::Run [0x004FCC9F+47] base::`anonymous namespace'::LaunchUnitTestsInternal [0x00DFF8C1+497] base::LaunchUnitTests [0x00DFF61D+109] main [0x00DF8410+80] __tmainCRTStartup [0x00DF6369+409] (f:\ddctools\crt\crtw32\dllstuff\crtexe.c:626) mainCRTStartup [0x00DF64AD+13] (f:\ddctools\crt\crtw32\dllstuff\crtexe.c:466) BaseThreadInitThunk [0x7638337A+18] RtlInitializeExceptionChain [0x76EC92B2+99] RtlInitializeExceptionChain [0x76EC9285+54] . |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
