speedscope icon indicating copy to clipboard operation
speedscope copied to clipboard

Add support for color scheme controls

Open nitsanw opened this issue 5 years ago • 1 comments

Thanks for a great tool!

In B.Gregg reference implementation we have the --color option where users can pick a color scheme, and a preset color map which can be used to maintain color scheme across profiles (same method -> same name). This is particularly useful for differentiating kernel/native/C++/jit/inlined frames in a profile.

nitsanw avatar Sep 23 '18 13:09 nitsanw

Interesting! It seems like the relevant code is here:

https://github.com/brendangregg/FlameGraph/blob/18c3dea3b2c55ae66768936f1039e36a12b627f6/flamegraph.pl#L371-L480

I spent quite a lot of time making the color scheme for speedscope both visually appealing and semantically meaningful by clustering related symbols into similar colors, so I think I would want something more nuanced than the reference implementation, but it's an interesting idea.

The color scheming at the moment works by sorting all of the symbols by their full qualified name including file path information, then mapping those sorted symbols onto a square wave moving in HCL space:

https://github.com/jlfwong/speedscope/blob/c70171836c79b59d65f5515020da37591a4bb4dd/src/gl/flamechart-color-pass-renderer.ts#L52-L58

This means that all profiles will use the full range of the available color space, but also means that the same symbol will not always map to the same color.

Speedscope has the benefit of having access to the raw profile information in many cases, so it could potentially make much more accurate distinctions between different categories of call-frames.

Correct me if I'm wrong, but I think there are a few separate requests in this PR:

  1. Provide an interface to select a color scheme, either through UI controls or via URL parameters
  2. Provide a method which provides a color scheming option which always maps the same symbol to the same color
  3. Provide a method which partitions symbols into a few semantically useful sets, then applies a different color schema strategy to each partition

jlfwong avatar Sep 24 '18 18:09 jlfwong