-
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
restore combine.sh bash performance while still sticking to POSIX #3241
Conversation
Hi @wahern! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
1 similar comment
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
…ating search patterns in combine.sh list_has_item
Looks great ! cc @cwoffenden |
This looks good! (I'll give it a quick test on some old Unixes at the weekend) |
Resurrecting this... I eventually got round to booting up an old Mac (Leopard on PPC) and out-of-the-box the shell script fails, but it's always failed on there because the Anyway, replacing the system Part of the reason it still takes so long, at least on this machine, is because the resulting I'm not sure it's worth the time to test for ggrep, since anyone installing MacPorts will have probably added Python, but I think it worth verifying on other systems that the amalgamated library isn't larger than needs be. I think it breaks because of changes to how the headers are included. The Python version runs zstd/build/single_file_libs/combine.py Line 113 in fba704f
(After writing all of this I feel a bug report would've been better...) |
Indeed, a |
POSIX sh
case
statement is just as fast Bash's=~
extended test operator. It takes a glob pattern, though, so this patch uses it to short-circuit before falling back to grep. This patch effectively restores the original Bash performance, at least as compared with macOS /bin/bash and using the three older Bash regex tests. (It's negligibly slower on account of the #include and #pragma tests being called through a function rather than inline within the if statement.)I experimented with POSIX expr(1), which takes BREs, but it's not a built-in on FreeBSD, macOS, or OpenBSD /bin/sh and wasn't any faster than invoking grep.
fnmatch function signature comes from Rich Felker's http://www.etalabs.net/sh_tricks.html