profiling.sampling – Statistical Profiler

· coding · Source ↗

TLDR

  • Python 3.15 adds profiling.sampling (Tachyon): a zero-overhead statistical profiler that attaches to live processes without code changes.

Key Takeaways

  • Tachyon reads call stacks from external process memory at configurable rates (default ~10 kHz), estimating time via sample counts times interval.
  • attach and dump subcommands work on running PIDs with no restart required; dump is useful for hung/unresponsive processes.
  • Output formats include flame graphs (HTML), gecko JSON for Firefox Profiler, line-by-line heatmaps, and opcode-level bytecode views.
  • Not suited for sub-second scripts, exact call counts, or sub-2% micro-benchmark comparisons; use profiling.tracing or timeit there.
  • Production guidelines: profile under representative load, start with 10-30s windows, and note that the profiler consumes CPU on the observer machine, not the target.

Hacker News Comment Review

  • The sole comment reflects that a stdlib statistical profiler was long expected to require a third-party tool; shipping it in 3.15 is seen as a meaningful batteries-included win.

Original | Discuss on HN