freenode
Kernel & Low-Level

Linux perf drops embedded Python for standalone scripts

Ian Rogers's 49-patch series finishes moving perf analysis scripts onto a C extension module, cutting overhead and build complexity.

Linux perf is set to stop embedding a Python interpreter inside the tool itself. Ian Rogers has posted a 49-patch series that finishes migrating scripting support to ordinary standalone Python programs driven by a perf C extension module, and removes the last of the embedded libpython path.

For years, perf script ran Python and Perl by loading their libraries into the perf process. That design forced a full Python dictionary for every event whether a script used the fields or not, tangled build systems with specific interpreter libraries, and complicated threading and interpreter lifetime. Perl embedding was already gone in earlier merged work; this series completes the Python side.

The payoff is practical. Rogers reports a sharp speedup on common workloads. In one case, analyzing a short memory capture with mem-phys-addr took on the order of several seconds under the embedded engine and became a normal standalone Python run once rewritten against the extension. Scripts no longer depend on Qt/PySide solely to talk to SQLite or PostgreSQL: the exporters use the standard library and libpq, so headless machines can dump traces without a GUI stack. Intel PT, CoreSight disassembly, net drop monitoring, PowerPC hypercall stats, and related utilities move with the same model, with type annotations and shell tests added along the way.

After the ports land, build detection shifts from "is libpython present" to "can we build the Python extension," legacy script install paths disappear, and the TUI script browser looks for the new standalone layout. For anyone packaging or scripting perf, the contract becomes clearer: treat analysis as external Python that imports perf, not as code executed inside the binary.