firefox-devtools / firefox-devtools/profiler
Add "dynamic" category colors
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 491
- Avg merge
- 3d 46m
- Merged PRs (30d)
- 27
Description
Categories are determined at profile recording time. Categories cannot depend on information from symbolication: At the time when symbolication happens, it is too late to change categories.
However, for profiles captured with external tools such as perfrecord, it would be great to have different colors for different "parts of code", even if those different functions are from the same category.
Examples:
* Code in different native libraries (e.g. different system libraries) could have different colors.
* If we have filenames, especially if we have special paths like `git:::` or `cargo:::`, code from different repos or from different Rust dependencies could have different colors, even if all that code was compiled into the same native library.
* If we have absolute local filenames, code from different "root directories" could have different colors, e.g. stdlib vs main repo.
I propose that we add a new special category color named "dynamic".
Then, whenever we look up the color for a category, we change the lookup to be based on (category, path ?? resourceName). Normal categories will still resolve to the same color as today, ind will ignore the extra string. But the new "dynamic" color will resolve to a color that is picked from the rainbow based on the hash of the crate / repo / root directory / library name. Maybe we can split the 360º color wheel into 15 or so segments, ideally in the [OKHSV color space](https://bottosson.github.io/misc/colorpicker/#60f62a). The idea of using the string hash is that repeated profiling of the same code should keep consistent colors even as the profiled workload shifts between different parts of the code.
┆Issue is synchronized with this [Jira Task](https://mozilla-hub.atlassian.net/browse/FP-473)
Contributor guide
Assessment
This issue has not been assessed yet.