Skip to content

Show calls to native code and GC in profiles #140643

@brandtbucher

Description

@brandtbucher

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.

Linked PRs

Metadata

Metadata

Assignees

Labels

3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)sprintstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions