Feature or enhancement
Without too much effort (and negligible overhead in the profiler), we can add some useful additional functionality to the new sampling profiler:
- Show calls through native code in the collected stacks. Note that this doesn't show symbols for the native code itself (that's a much more invasive, fragile change). Rather we already have enough information when walking the Python stack to detect when we leave and reenter the interpreter (for example, by calling through a builtin function or C extension), and insert a dummy
<native>frame in the collected stack between the Python frames. - Even more usefully, we can show where/when garbage collections are occurring, and denote these with
<GC>dummy frames. Any Python code running in finalizers, GC callbacks, or weakref callbacks will be below these in the stack.
@pablogsal and I discussed this at the sprint, and he seemed excited for it. I implemented most of it there, and will open a PR shortly once I've cleaned things up a bit and added docs.