Repository navigation
device_memory_report: lazily initialize CounterTrack instances - #33
Merged
olehkuznetsov merged 6 commits intoSep 17, 2026
Conversation
Static CounterTrack instances constructed at static initialization time lack process context (parent_uuid), which prevents Perfetto tracks from scoping under the process and being associated with the target application track group. Initializing tracks on first use inside GetCounterTrack ensures they properly bind to ProcessTrack::Current().
Add regression tests covering the lazy CounterTrack initialization fix. Tracks constructed at static initialization time were created before perfetto::Tracing::Initialize() assigned Track::process_uuid, so they ended up with parent_uuid == 0 and were emitted as global tracks instead of being scoped under the process.
olehkuznetsov
left a comment
There was a problem hiding this comment.
Reviewed the lazy CounterTrack initialization and process-scoping tests.
Run GetCounterTrackInitializesTracing in a fresh child process via EXPECT_EXIT with threadsafe death test mode so it tests cold Perfetto initialization from uninitialized static state.
…rdown - Declare track_names before tracks to preserve LIFO static destruction order. - Defer InitializeDeviceMemoryReportPerfetto() until cache miss to avoid std::call_once on fast path. - Emplace string keys directly from string_view and pass const std::string& to DynamicString.
…g test Now that static pre-registered tracks have been removed in favor of lazy creation, remove the obsolete comment about pre-registered tracks.
olehkuznetsov
approved these changes
Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Static CounterTrack instances constructed at static initialization time lack process context (parent_uuid), which prevents Perfetto tracks from scoping under the process and being associated with the target application track group. Initializing tracks on first use inside GetCounterTrack ensures they properly bind to ProcessTrack::Current(). It also has the benefit of making the code much terser.