Python Can Run Up To ~27% Faster On Fedora 32 With Optimization

Written by Michael Larabel in Fedora on 11 January 2020 at 07:09 AM EST. 19 Comments
FEDORA
Python scripts may be running noticeably faster come the release of Fedora 32 in April.

Originally for Fedora 32 the developers were looking at statically linking Python for better performance. But due to feedback, they reduced that scope and for their Python optimizations in Fedora 32 limited it to building Python with the -fno-semantic-interposition compiler flag.

Per the GCC documentation on the semantic interposition flag, "Some object formats, like ELF, allow interposing of symbols by the dynamic linker. This means that for symbols exported from the DSO, the compiler cannot perform interprocedural propagation, inlining and other optimizations in anticipation that the function or variable in question may change. While this feature is useful, for example, to rewrite memory allocation functions by a debugging implementation, it is expensive in the terms of code quality. With -fno-semantic-interposition the compiler assumes that if interposition happens for functions the overwriting function will have precisely the same semantics (and side effects). Similarly if interposition happens for variables, the constructor of the variable will be the same. The flag has no effect for functions explicitly declared inline (where it is never allowed for interposition to change semantics) and for symbols explicitly declared weak."

Fedora developers found that building Python with -fno-semantic-interposition can yield up to 27% higher performance depending upon the workload. Test cases like nbody, scimark, django, ray-tracing, and many others yielded performance improvements in the range of 20~27% with a whole lot more delivering improvements in the 5~20% range as measured by PyPerformance.

The only minor downside to this change of no semantic interposition is that LD_PRELOAD cannot be used with Python for overriding symbols, but that shouldn't affect many.

More details on this completed change on the Fedora Wiki.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week