flamegraph icon indicating copy to clipboard operation
flamegraph copied to clipboard

Add option to svg to rescale to a certain function

Open Haroenv opened this issue 2 years ago • 3 comments

If there's a specific part of the program you want to optimise, let's say a single function, you'll run the flame graph tool and that function will take a certain amount of time of the whole graph. If you then make an improvement, you'll be able to measure how much time has changed in that main function compared to the whole graph fairly easily.

However, it's likely that a certain operation didn't get done the same amount of times (eg. in the case of a server, you won't get the same amount of requests), but you'll still get the same ratio within that function.

What then becomes cumbersome is trying to find out how much impact a certain change has. Let's say you have the main function taking 43% in the first profile, and 49% in the next, but what you're trying to profile inside of that is 15% in the first and 14% in the second. You can tell it made an improvement.

What becomes hard is to know how large that improvement is relative to the "main" function, not the whole profile. It would be interesting that if you select a certain part of the trace, all child traces would (in brackets maybe?) have the ratio within the function which is currently focused too.

If there's already a way to get that info, I'm also very happy of course 👍

For now my workaround is calculating myself by dividing the number of samples of my optimised subfunction to the main function in both traces, which can give a percentage (583/1611, 36.19% in one and 538/1852, 29.05% in the other one).

Haroenv avatar Jan 29 '22 21:01 Haroenv

flamegraph is basically a wrapper around the inferno library, which helps collect perf or dtrace data, then passes it to perf. I think this feature request is something that ought to be implemented in inferno (if it does not already exist).

djc avatar Jan 29 '22 21:01 djc

Thanks, that makes sense. I opened https://github.com/jonhoo/inferno/issues/228 instead!

Haroenv avatar Jan 30 '22 12:01 Haroenv

I'll keep this open, if/once this is implemented in inferno we'll need to do some work on the CLI to forward the configuration.

djc avatar Jan 30 '22 13:01 djc