mstange / samply

Command-line sampling profiler for macOS and Linux
Apache License 2.0
2.36k stars 58 forks source link

Feature Request: Ability to track deep recursion using frame pointers. #126

Open hargoniX opened 8 months ago

hargoniX commented 8 months ago

In programs with very deep recursion samply begins producing flamegraphs that are "chopped apart" like in the below picture: image

(Link to profile: https://share.firefox.dev/49aeiVw) The majority of these calls are in fact not happening at the same stack depth but are instead part of a very deep recursion in the profiled program. Even setting kernel.perf_event_max_stack to a high value does not help in this situation.

perf together with a perf.data visualizer like flamegraph.pl on the other hand, can make use of the framepointer that is included in this build of the binary to produce a more accurate flamegraph:

image

And then futher up: image

It would be very nice if samply provided an option to track deep recursion. Presumably using framepointers as the current approach appears to be unable of doing this?

ishitatsuyuki commented 7 months ago

FWIW you can perf record then load the resulting perf.data into Firefox Profiler UI with samply load perf.data. This should give you a decent workaround in the meantime.

samply does support kernel-provided stacks but it's not exposed right now. Ideally we should make more of perf_event_attr we pass to the kernel configurable.