Open SyamGadde opened 2 years ago
I'm not a greenlet expert, but as I understand it, g_switch
is the "root" of the native stack for greenlets. I don't know how gdb decides "here's where the stack ends and I should stop unwinding". I assume that the way greenlet sets up the stack is different from how standard threads look like, and therefore, gdb doesn't know when to stop. So what you're seeing below g_switch
is basically garbage. Not 100% confident in this analysis though.
I think that the best solution here is your first suggestion - cut everything after g_switch
.
Troublemaker back again! py-spy seems to be the only Python statistical profiler that supports profiling Cython extensions and for that I am very grateful. I am again attempting to profile Cython extensions using the --native option and generally doing fine with the latest versions of everything on Python 3.6:
However, when I try the same on Python 3.9, a really annoying thing happens in greenlets. A side-by-side diff is shown below between two stacks as printed by gdb:
As you can see above, most of the entries are the same and would be merged together in a flamegraph output from py-spy... EXCEPT for the fact that the stack frame just below the g_switch changes addresses every so often, which results in essentially N independent flame graphs rather than one hierarchical flame graph. Does anyone have guidance for me on why this might happen (only on Python 3.9) and/or how to get py-spy to work with this?
I guess one hacky option would be to have it somehow ignore the line below the last g_switch, or stop at the first frame that has a ?? for the function name, which I can explore, but any other solutions are welcome!