Profiling at the speed of light
summary
Python 3.12 adds one of the world's smallest JIT compilers by injecting tiny assembly trampolines so Linux perf can attribute samples to Python frames; perf plus frame pointers or DWARF augmentation produces combined C+Python flame graphs. A shuffled-vs-sorted example runs ~950ms vs ~600ms (≈55% slower) and perf shows the slow path copies many small chunks in C, not branch mispredictions. Tools used: perf record/report/probe, flamegraphs, hotspot and GDB; the implementation works with caveats about frame pointers, DWARF overhead, and sampling costs.
AI-written summary · about
chapters (6)
- 0:00The performance mystery
- 2:00Limitations of standard tools
- 7:12Teaching perf to read Python
- 14:24Stack unwinding strategies
- 21:38Solving the mystery
- 24:58Advanced profiling applications
related talks
01h 31mDebugging and profiling techniques
01h 03mA tour of CPython's runtime
21mFrom PyPerf to py-spy - Everything You Need to Know About Python Profilers
37mTuning Python applications can dramatically increase performance
57mPython and PyPy performance (not) for dummies
22mExperiences making CPU-bound tasks run much faster
26mPython Performance at Scale - Making Python Faster at Instagram
41mHow to write a JIT compiler in 30 minutes
