indygreg / python-build-standalone

Produce redistributable builds of Python
BSD 3-Clause "New" or "Revised" License
1.71k stars 107 forks source link

Consider adding a variant that disables semantic interposition #200

Closed ofek closed 6 months ago

ofek commented 6 months ago

I was reading about that here which apparently had a 30% performance improvement https://developers.redhat.com/blog/2020/06/25/red-hat-enterprise-linux-8-2-brings-faster-python-3-8-run-speeds

I have no idea if this even makes sense to do but thought I would ask 🙂

cipriancraciun commented 6 months ago

Looking at the article in question, it seems it's related to the way GCC handles calls to dynamically loaded functions, namely the optimization (-fno-semantic-interposition) allows GCC to inline (via LTO) some libpython.so functions without passing through the dynamic function table lookup.

Given that this Python build is already quite "special", perhaps this flag wouldn't break the way in which this build is being used.

So, if it really yields a ~30% performance improvement (over what Python 3.11 already provides) I would vote for it. :)

indygreg commented 6 months ago

This project uses Clang to build CPython. And my understanding is that Clang by default has the equivalent behavior of GCC's -fno-semantic-interposition. So there should be nothing to do here.

I encourage others to benchmark PBS builds against other CPython builds. I consider performance deficiencies to be a bug. my limited testing has shown that PBS performance wise is no worse - often better - than other CPython builds - at least on Linux and macOS. I don't anticipate Windows having any major performance differences since the build systems are nearly identical.