-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to svg to rescale to a certain function #228
Comments
That's an interesting idea! I think you could implement this as a feature of the "zoom" functionality. Basically, when you zoom into an element, walk all the stack frames above the zoomed-in frame and compute their sample count relative to the width of the target frame, then display that ratio as a percentage next to the "total" percentage. It'll take a little finagling to actually find "all stacks above this one", but should be doable I think. If you have the chance to take a stab at a PR, that'd be very welcome! Since this likely only affects the JavaScript in the SVG, you might even be able to contribute it back to the upstream https://github.com/brendangregg/FlameGraph/. |
Nice, that's what I had in mind too. Were you thinking something like: What word should be used for zoom? Maybe also "focus" is a possibility. I'll have a look if I can make a PR! |
Exactly! How about:
|
Sounds good! I had a look into the JS, but didn't yet figure out which parts were responsible for showing the titles, it seems they might be calculated when creating the initial svg, so we'll need to walk up the dom manually possibly? |
Yeah, I think you may have to walk up the elements dynamically, which isn't great, but may be necessary. We'll need a somewhat efficient way to do it though. And we'll probably want to stop at a given depth so that it doesn't end up slowing things down too much for very large graphs. |
Any update on this? brendangregg/FlameGraph appears to have this functionality already. |
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).
I originally opened flamegraph-rs/flamegraph#190, but was referred that the actual flame graph portion of that library is done here
The text was updated successfully, but these errors were encountered: