◐ Shell
clean mode source ↗

gh-142927: Hide _sync_coordinator frames from profiler output by pablogsal · Pull Request #143337 · python/cpython

@pablogsal

When running scripts via "python -m profiling.sampling run", the internal
_sync_coordinator module appears in stack traces between runpy and user
code. These frames are implementation details that clutter the output and
provide no useful information to users analyzing their program's behavior.

The fix adds a filter_internal_frames function that removes frames from
_sync_coordinator.py anywhere in the call stack. This is applied in both
the base Collector._iter_all_frames method and directly in GeckoCollector
which bypasses the iterator. Tests cover all collector types: pstats,
flamegraph, collapsed stack, and gecko formats.