gh-103295: expose API for writing perf map files by gsallam · Pull Request #103546 · python/cpython (original) (raw)
#96123 added support for CPython to write /tmp/perf-.map files, associating instruction address ranges with a human-readable frame name for the Linux perf profiler.
Two external Python JIT compilers, Cinder and Pyston, both also independently write to perf map files.
Since perf map files are one-per-process, multiple separate libraries trying to write perf map entries independently can lead to file corruption from simultaneous writes.
It's unlikely for both Cinder and Pyston JITs to be used in the same process, but it's quite reasonable to use one of these JITs along with CPython's native perf trampoline support.
This PR add a C-API to write to the perf map file. It also update the perf trampoline to use the new API to write to the perf map file.