-
Notifications
You must be signed in to change notification settings - Fork 2.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
Use faster Python script to amalgamate #3005
Conversation
Thanks @cwoffenden 👍 , |
Made the Python more Python-like. Added notes and general tidy. Tested exclusions and building with various options. Tested all scripts.
This is done and tidied. I limited running the Python version to 3.8 (and higher) though it may work on earlier versions (testing was only done on 3.8). The Python is as Python-like as I know how (I'm not a Python guy), has the type annotations and has been passed through I changed the amalgamation scripts to use the And it's fast, even on my 2013 Mac Pro:
Consistently less than 0.2s vs nearly 3m previously (for the decoder lib), so over a thousand times faster. |
Added bonus: the Python script also works on Windows. In theory the shell script did, with the Git shell support, for example, but would take hours. It takes longer than on macOS on the same machine, completing in 0.6s:
|
When testing amalgamating other projects it was found: invalid Unicode errors were tripping Python's text IO, and the header search order appears differs from the shell version.
This has had further testing and edge cases fixed. I can now call it done. |
Co-authored-by: Alexandre Bury <alexandre.bury@gmail.com>
minor question : It seems the new recipe needs to explicitly exclude |
The input file always stripped out certain features, primarily to reduce the size when this was just the decompressor alone, e.g.:
In the original version of tool there wasn't the I can add it back in, if you'd prefer? It removed 50k-ish from the generated source, which the compiler skips over because those parts are currently if'd out. |
I think it's a pretty good reason. |
I made the |
Thanks @cwoffenden ! |
As mentioned in #2924 the
sh
amalgamation script is extremely, unusably slow. This faster Python version completes almost instantly. TL;DR where it used to take over 6.5 minutes for the full library it now takes a 1/3 of a second (on this old, old Mac Pro). Testing on an M1 Mac it takes 0.095 seconds to run the same.When developing the original single file decoder a Bash script was used, which completed in reasonable time, but didn't work with Zstd's CI on older OS/machine combos. This Python version was the working replacement but never supported all of the command line flags (I'll add them in the next days if there's interest, before calling this done).
Some numbers before:
And after:
The creation scripts first test that Python 3.8 or higher is installed, and if not the original shell script is run instead.
If there's interest in taking this I'll spend a few hours to make sure all the flags are supported and tested. As it stands it doesn't support excluding, which isn't used by Zstd anyway (it is in other projects).