-
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
Why is python shipped with the python
docker image slower than that of my local machine?
#825
Comments
#575 might have some useful ideas/info/discussion in it for you |
This comment was marked as spam.
This comment was marked as spam.
For what it's worth, with_debug isn't known to have any performance impact, other than a bit larger binary size. There are several (non-Python) discussions about this, for example: https://stackoverflow.com/questions/8676466/how-do-debug-symbols-affect-performance-of-a-linux-executable-compiled-by-gcc I'd guess the slowdown is likely due to container security overhead. You should try to run your tests with |
Docker itself would add more overhead on top of that unless some security features are disabled (i.e. running the tests in docker with |
I see, I didn't catch the Docker Python binary was extracted, then tested. Although, I looked around a bit more and couldn't find any evidence that the debug symbols hurt performance. If you still have the test set up, it looks like you can strip a binary after it was compiled with |
Cool, I ran some quick (read: could be unreliable) benchmarks with Python 3.12.1 from the official Docker image and from Deadsnakes. I also ran a test with a stripped version of the Docker binary. These tests were run inside Docker, the official binary within the official container and Deadsnake binary in the latest Ubuntu container. All on my Mac M1 laptop. I ran the Results:
Official Docker binary vs same binary, but with
And finally, stripped official binary vs Deadsnake:
Analysis: The other open question is how would stripping these symbols affect usage? That's not clear to me, and we would need to weigh that vs the small performance bump. There seems to be other open tickets requesting more debug info, so I'm not sure if these symbols are doing anything at all? |
Interesting. It looks like the
And indeed, the slim binaries are faster than non-slim:
Since people do use the slim package for optimizing file size, I think it makes sense to use it when you want to get a bit better performance at the cost of "debuggability". Maybe this performance difference should be documented somewhere, but I think the answer to this issue is just to use the slim images. |
@SimonLammer you should really add this to the title and/or original post. otherwise the answer is essentially "duh". the trade off for docker is more security and specified environment at the cost of speed. |
Note that these benchmarks are not using the |
I've observed a roughly 11% performance overhead when using the python distribution shipped with the
python:3
image, compared to the python distribution installable throughppa:deadsnakes/ppa
: https://stackoverflow.com/a/76133102/2808520My guess is that the
with debug_info
compilation introduces this ~11% performance overhead.I'd appreciate if someone could tell me if my guess is correct.
The text was updated successfully, but these errors were encountered: