-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable semantic interposition? #501
Comments
This Fedora wiki has some benchmarks from the change: https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup |
This is neat! Do you know if there's been any attempt to bring this suggestion upstream? (and/or any official recommendation from upstream to set this flag?) |
It would appear that https://bugs.python.org/issue38980 is the appropriate upstream discussion. 👍 |
Nice. There's some good points in that python.org thread in favor of the option, like Clang disabling it by default already. I wonder if adding the option to the Docker images would help upstream make a decision? |
We follow their lead as to how they would like to Python built. We aspire to represent how Python maintainers desire Python to be built as purely as possible. When they reach a decision to change the default, we will definitely use it. |
i'll focus on the upstream issue. But the simple answer is that if you test this with your interpreter's build + configure setup and it makes a demonstrable improvement that you can measure. I'd go ahead and adopt it. |
That's great, thank you for the feedback. You're right, we should do an actual test on this specific case. I ran a quick benchmark.
Not quite the numbers that Red Hat was seeing, but adding LTO does seem to have a significant impact. |
Getting similar results with Alpine 3.12 with LTO and
|
Interesting results, although I'm not sure this is very convincing WRT Additionally, I want to make sure we're careful with the build-time implications of this, which is why we resisted |
To illustrate better what I mean, the build of |
Fair point. I actually did do an LTO-only test when I did the other tests. I don't have the results now, but they were interesting. Mostly no changes in performance, some tests were even slower. I believe LTO only works when function calls don't go through the lookup table, like when the I remember also testing |
OK, I took some time to run more tests: https://gist.github.com/blopker/87153749077fc2ca233310627a564e42 |
Ok, the results with rigorous didn't change too much, there was still a lot of variance with the quick tests. I think the only way to get those more consistent is to get a dedicated host to run on, but that's more $$. Seems like most of the performance gains are more than 10%. Is there any other information that would be useful? |
Some good news on this! Looks like To get the full performance benefits we'll still need to add |
With Python 3.10 soon to release, to get this performance improvement should we use the |
Was this optimization included in the This line would imply it was? python/3.10/bullseye/Dockerfile Line 44 in 35fa20f
|
These are the results from adding
From this it looks like |
Debian's been building their own Python distro package using LTO since forever. You can But they don't appear to be using the builtin Python's configure Along with another step using sed that appears to strip such flags from the generated sysconfig module to avoid issues with that? |
Interesting find. It looks like the patches are also applied to Python 2.7. Looking for the patch (link-opt.diff) on Google, it seems to predate the |
OK, I created a PR to only apply |
Fix #501: add --with-lto to 3.10 and newer
Changes: - docker-library/python@70b2802: Merge pull request docker-library/python#660 from blopker/feature/with-lto - docker-library/python@1fa00a0: Fix docker-library/python#501: add --with-lto to 3.10 and newer - docker-library/python@35fa20f: Update to 3.8.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@5665256: Update to 3.6.15, setuptools 57.5.0, pip 21.2.4 - docker-library/python@b6b534f: Update to 3.7.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@62ec6a1: Update to 3.11.0a1, setuptools 57.5.0, pip 21.2.4 - docker-library/python@1c48a50: Update to 3.9.7, setuptools 57.5.0, pip 21.2.4 - docker-library/python@652ed14: Update to 3.10.0, setuptools 57.5.0, pip 21.2.4
Changes: - docker-library/python@9242c44: Update to 3.8.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@59a27ea: Update to 3.6.15, setuptools 57.5.0, pip 21.2.4 - docker-library/python@a765583: Update to 3.7.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@1f16f24: Update to 3.11.0a1, setuptools 57.5.0, pip 21.2.4 - docker-library/python@a7ff0b7: Update to 3.9.7, setuptools 57.5.0, pip 21.2.4 - docker-library/python@8e59156: Update to 3.10.0, setuptools 57.5.0, pip 21.2.4 - docker-library/python@70b2802: Merge pull request docker-library/python#660 from blopker/feature/with-lto - docker-library/python@1fa00a0: Fix docker-library/python#501: add --with-lto to 3.10 and newer - docker-library/python@35fa20f: Update to 3.8.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@5665256: Update to 3.6.15, setuptools 57.5.0, pip 21.2.4 - docker-library/python@b6b534f: Update to 3.7.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@62ec6a1: Update to 3.11.0a1, setuptools 57.5.0, pip 21.2.4 - docker-library/python@1c48a50: Update to 3.9.7, setuptools 57.5.0, pip 21.2.4 - docker-library/python@652ed14: Update to 3.10.0, setuptools 57.5.0, pip 21.2.4
Changes: - docker-library/python@9242c44: Update to 3.8.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@59a27ea: Update to 3.6.15, setuptools 57.5.0, pip 21.2.4 - docker-library/python@a765583: Update to 3.7.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@1f16f24: Update to 3.11.0a1, setuptools 57.5.0, pip 21.2.4 - docker-library/python@a7ff0b7: Update to 3.9.7, setuptools 57.5.0, pip 21.2.4 - docker-library/python@8e59156: Update to 3.10.0, setuptools 57.5.0, pip 21.2.4 - docker-library/python@70b2802: Merge pull request docker-library/python#660 from blopker/feature/with-lto - docker-library/python@1fa00a0: Fix docker-library/python#501: add --with-lto to 3.10 and newer - docker-library/python@35fa20f: Update to 3.8.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@5665256: Update to 3.6.15, setuptools 57.5.0, pip 21.2.4 - docker-library/python@b6b534f: Update to 3.7.12, setuptools 57.5.0, pip 21.2.4 - docker-library/python@62ec6a1: Update to 3.11.0a1, setuptools 57.5.0, pip 21.2.4 - docker-library/python@1c48a50: Update to 3.9.7, setuptools 57.5.0, pip 21.2.4 - docker-library/python@652ed14: Update to 3.10.0, setuptools 57.5.0, pip 21.2.4
Red Hat recently released an article about how they improved Python's performance by 30% in Python 3.8 by disabling semantic interposition. Article: https://developers.redhat.com/blog/2020/06/25/red-hat-enterprise-linux-8-2-brings-faster-python-3-8-run-speeds/
Looks like they added the
-fno-semantic-interposition
flag to GCC.Would this option make sense for this image?
The text was updated successfully, but these errors were encountered: