@@ -29,7 +29,7 @@ This PEP proposes two things:
2929 with frame pointers by default. ** This PEP recommends that *every * compiled
3030 component that participates in the Python call stack (C extensions, Rust
3131 extensions, embedding applications, and native libraries) should enable
32- frame pointers. A frame-pointer chain is only as complete as its weakest
32+ frame pointers. A frame-pointer chain is only as strong as its weakest
3333 link: a single library without frame pointers breaks profiling, debugging,
3434 and tracing for the entire process.
3535
@@ -101,8 +101,8 @@ the entire call stack::
101101Stack unwinding is the process of walking this chain to reconstruct the call
102102stack. Profilers do it to find out where the program is spending time;
103103debuggers do it to show backtraces; crash handlers do it to produce useful
104- error reports. With frame pointers, unwinding is a simple pointer chase : read
105- ``%rbp ``, follow the link, repeat. It takes microseconds and requires no
104+ error reports. With frame pointers, unwinding is a simply following pointers : read
105+ ``%rbp ``, follow the link, repeat. It is very fast and requires no
106106external data.
107107
108108At optimisation levels ``-O1 `` and above, GCC and Clang omit frame pointers by
@@ -322,15 +322,14 @@ BPF programs for production monitoring), frame pointers are the only viable
322322unwinding mechanism because they are the only mechanism the kernel's built-in
323323helpers support.
324324
325- CPython's own documentation already states the recommended fix::
325+ :ref: `CPython's own documentation <python:perf_profiling >`__ already states the
326+ recommended fix:
326327
327328 For best results, Python should be compiled with
328- CFLAGS=' -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer'
329+ `` CFLAGS=" -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"``
329330 as this allows profilers to unwind using only the frame pointer
330331 and not on DWARF debug information.
331332
332- -- docs.python.org/3/howto/perf_profiling.html
333-
334333Production profiling tools echo this guidance. Grafana Pyroscope's
335334troubleshooting documentation states: "If your profiles show many shallow stack
336335traces, typically 1-2 frames deep, your binary might have been compiled without
@@ -359,16 +358,14 @@ Distributions Are Waiting for Upstream
359358
360359Fedora 38 [#fedora38 ]_, Ubuntu 24.04 LTS [#ubuntu2404 ]_, and Arch Linux have
361360all rebuilt their entire package trees with ``-fno-omit-frame-pointer
362- -mno-omit-leaf-frame-pointer ``. However, Ubuntu 24.04 LTS explicitly exempted
363- CPython::
361+ -mno-omit-leaf-frame-pointer ``. However, Ubuntu 24.04 LTS
362+ `explicitly exempted CPython
363+ <https://ubuntu.com/blog/ubuntu-performance-engineering-with-frame-pointers-by-default> `__:
364364
365365 In cases where the impact is high (such as the Python
366366 interpreter), we'll continue to omit frame pointers until
367367 this is addressed.
368368
369- -- ubuntu.com/blog/ubuntu-performance-engineering-with-
370- frame-pointers-by-default
371-
372369The result is a circular dependency: the runtime most in need of frame pointers
373370for profiling is the one that major distributions leave without them, pending
374371an upstream fix. Red Hat Enterprise Linux and CentOS Stream also disable frame
@@ -395,7 +392,7 @@ The need for a continuous chain is precisely why the flags must propagate to
395392extension builds. If only the interpreter has frame pointers but extensions do
396393not, the chain is still broken at every C extension boundary. By adding the
397394flags to ``CFLAGS `` as reported by ``sysconfig ``, extension builds that consume
398- CPython's compiler flags (for example via ``pip install ``, `` setuptools `` , or
395+ CPython's compiler flags (for example via ``pip install ``, Setuptools , or
399396``python setup.py build ``) will inherit frame pointers by default. Extensions
400397and libraries with independent build systems still need to enable the same
401398flags themselves for the frame-pointer chain to remain continuous.
@@ -517,7 +514,7 @@ Ecosystem Impact
517514
518515Because the flags are in ``CFLAGS ``, they propagate automatically to consumers
519516that build against CPython's reported compiler flags, such as C extensions
520- built via `` pip ``, `` setuptools `` , or direct ``sysconfig `` queries. Those
517+ built via pip, Setuptools , or direct ``sysconfig `` queries. Those
521518consumers need take no additional action to benefit from this change.
522519
523520Not all compiled code in the Python ecosystem inherits CPython's ``CFLAGS ``.
0 commit comments