Skip to content

Conversation

@g-aattar
Copy link
Contributor

@g-aattar g-aattar commented Oct 9, 2025

This improves the Perfetto UI by assigning a distinct color to anonymized threads and optimizing the color generation logic for better performance and readability.

Changes:

  • Gray for Anonymized Threads: The colorForThread function now identifies threads named "Anonymized Process" (originating from the ETW parser) and assigns them a gray color. This makes them easy to distinguish on CPU tracks.
  • Performance Optimization: A cache (Map) has been added to the colorForTid function. This memoizes results based on the thread ID, avoiding repeated string conversions and hashing in hot render paths.
  • Improved Readability: The magic string "Anonymized Process" was extracted into a named constant with a comment indicating its source.
  • Testing: Added and updated unit tests to verify the new coloring logic and ensure the caching mechanism works as expected.

@g-aattar g-aattar marked this pull request as ready for review October 9, 2025 18:49
@g-aattar g-aattar requested a review from a team as a code owner October 9, 2025 18:49
return colorScheme;
}

// From src/trace_processor/importers/etw/etw_parser.cc
Copy link
Member

@LalitMaganti LalitMaganti Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but this not a hack we can accept in the core UI. Please follow the guidance I gave on the chat on how to expose this properly (new column in thread table, using that column in the sched plugin) rather than hacking core classes in the UI like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconded

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will make the appropriate changes. Thanks for the info!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants