conda-forge / python-feedstock

A conda-smithy repository for python.
BSD 3-Clause "New" or "Revised" License
46 stars 105 forks source link

Investigate -fno-semantic-interposition build option #287

Open rth opened 4 years ago

rth commented 4 years ago

Fedora 32 has a proposal to build python with with -fno-semantic-interposition for better performance (https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup),

We add the -fno-semantic-interposition compiler/linker flag when building Python interpreters, as it provides significant performance improvement, up to 27% depending on the workload. Users will no longer be able to use LD_PRELOAD to override a symbol from libpython, which we consider a good trade off for the speedup.

It would be interesting to investigate whether the same could be done for conda-forge Linux (and possibly MacOS) builds.

jakirkham commented 4 years ago

cc @jjhelmus @mingwandroid (as you may have thoughts here 😉)

mingwandroid commented 4 years ago

Losing LD_PRELOAD is unfortunate. We could test it I suppose though.

jjhelmus commented 4 years ago

The current python conda packages are linked statically against libpython. I do not believe there would be any performance improvements from building with -fno-semantic-interposition since there is no dynamic libpython library to interpose.

Fedora dynamically links the python interpreter to libpython and therefore sees gains from building with -fno-semantic-interposition. The original Fedora proposal began with a discussion to statically link the interpreter to achieve performance gains.

mingwandroid commented 4 years ago

You can still interpose glibc.

mingwandroid commented 4 years ago

I expect the perf. gains in disabling that would be minimal though.

jjhelmus commented 4 years ago

According to the Fedora proposal it is still possible to interpose glibc and other libraries. Interposition is only disabled for libpython.

""" It is still possible to use LD_PRELOAD to override symbols in other libraries (for example in glibc). """

mingwandroid commented 4 years ago

OK then I don't think there's any point here, happy to be benchmarked wrong though.

rth commented 4 years ago

Thanks for investigating! Looks like this issue can be closed then?

mingwandroid commented 4 years ago

We do build a libpython dynamic library. We could still enable it for that if anyone cares?