Skip to content
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

LZMADecompressor is slow #327

Open
andiradulescu opened this issue Sep 9, 2024 · 5 comments
Open

LZMADecompressor is slow #327

andiradulescu opened this issue Sep 9, 2024 · 5 comments
Labels
performance Potential performance improvement

Comments

@andiradulescu
Copy link

Using uv python install to install python 3.12.3, decompress is ~2x slower than Ubuntu 24.04 python3 and also pyenv installed python. Same python version.

For example:

uv installed python:

$ python -V
Python 3.12.3
$ python decompress.py
Time taken to decompress: 0.001038 seconds

system python (from ubuntu):

$ /usr/bin/python -V
Python 3.12.3
$ /usr/bin/python decompress.py
Time taken to decompress: 0.000400 seconds
$ uv python list --only-installed
cpython-3.12.3-linux-aarch64-gnu    /usr/local/uv/python/cpython-3.12.3-linux-aarch64-gnu/bin/python3 -> python3.12

Also tried the same thing on macOS, same python 3.12 installed with pyenv vs installed with uv and I noticed the same thing.

I made tests with decompress.py and with multiple other xz files.

@zanieb
Copy link
Member

zanieb commented Sep 9, 2024

Interesting. Thanks for the report. Any clue why this could be?

@indygreg
Copy link
Collaborator

indygreg commented Sep 9, 2024

I have a hunch that the 2nd call from the same process will be faster and have similar performance as other builds.

@andiradulescu
Copy link
Author

Thanks for looking into this, we really need this fixed @commaai. We decompress a 800 MB xz update file and takes almost twice as much.

I tried figuring out the issue myself, but with no luck. If you give me a pointer on what to change, I may be able to fix it myself and PR it, but right now I have no idea.

@indygreg
Copy link
Collaborator

If you care about decompression wall times you should consider the zstandard Python package. xz/lzma will give you really good compression ratios but the decompression speeds are usually vastly slower than zstd.

@andiradulescu
Copy link
Author

andiradulescu commented Sep 10, 2024

We were thinking about switching to Zstandard, but didn't wanted to change the image format right now. Since we need to change the code in not just one place (but three) and also validate everything. We can't update it right now, so we hope for a fix.

I have a hunch that the 2nd call from the same process will be faster and have similar performance as other builds.

I tried running decompress multiple times in the same process, but the speed is the same. Did I understood your comment wrong?

@charliermarsh charliermarsh added the performance Potential performance improvement label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Potential performance improvement
Projects
None yet
Development

No branches or pull requests

4 participants