]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-140643: Add `<native>` and `<GC>` frames to the sampling profiler (#141108)
authorBrandt Bucher <brandt@python.org>
Mon, 17 Nov 2025 13:39:00 +0000 (05:39 -0800)
committerGitHub <noreply@github.com>
Mon, 17 Nov 2025 13:39:00 +0000 (13:39 +0000)
commit336366fd7ca61858572fdb78e2bd79014b215f19
tree38f7ba809af44753dee4d19924a8b7cda724b4cc
parent89a914c58db1661cb9da4f3b9e52c20bb4b02287
GH-140643: Add `<native>` and `<GC>` frames to the sampling profiler (#141108)

- Introduce a new field in the GC state to store the frame that initiated garbage collection.
- Update RemoteUnwinder to include options for including "<native>" and "<GC>" frames in the stack trace.
- Modify the sampling profiler to accept parameters for controlling the inclusion of native and GC frames.
- Enhance the stack collector to properly format and append these frames during profiling.
- Add tests to verify the correct behavior of the profiler with respect to native and GC frames, including options to exclude them.

Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
18 files changed:
Doc/library/profile.rst
Include/internal/pycore_debug_offsets.h
Include/internal/pycore_global_objects_fini_generated.h
Include/internal/pycore_global_strings.h
Include/internal/pycore_interp_structs.h
Include/internal/pycore_interpframe_structs.h
Include/internal/pycore_runtime_init_generated.h
Include/internal/pycore_unicodeobject_generated.h
Lib/profiling/sampling/flamegraph.js
Lib/profiling/sampling/sample.py
Lib/profiling/sampling/stack_collector.py
Lib/test/test_external_inspection.py
Lib/test/test_profiling/test_sampling_profiler.py
Misc/NEWS.d/next/Core_and_Builtins/2025-11-05-19-50-37.gh-issue-140643.QCEOqG.rst [new file with mode: 0644]
Modules/_remote_debugging_module.c
Modules/clinic/_remote_debugging_module.c.h
Python/gc.c
Python/gc_free_threading.c