From PyPerf to py-spy - Everything You Need to Know About Python Profilers
summary
Compares deterministic call-tracing with sampling via stack traces and shows how flamegraphs turn millions of samples into actionable hotspots. Describes py-spy (reads target Python process memory from a separate process) as low-overhead and non-intrusive but blind to native work that releases the GIL unless it pauses or trusts the GIL state. Demonstrates eBPF / PyPerf approaches that capture running-thread state and native stacks on Linux, producing accurate flamegraphs suitable for production; notes eBPF isn’t available on Windows.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:45Why profile code
- 2:26Deterministic profiling
- 4:55Flame graphs
- 7:38Sampling with Py-Spy
- 9:22Py-Spy example
- 11:03GIL limitations
- 12:01EBPF profilers
- 14:51Perf and takeaways
- 18:12Q&A
- 20:33Conclusion
related talks
31mTracing, Profiling & Debugging in Production (eBPF)
33mA Tale of Two Flamegraphs: Continuous Profiling in Ruby
32mProfiling at the speed of light
33mInto the flamegraph: From the primitives through advanced concepts
56mPython Profiling State of the World
01h 31mDebugging and profiling techniques
28mKnocking On A Process’s Door: Introspecting Live Python Processes
37mTuning Python applications can dramatically increase performance
