hashsum: improve hashsum using 32KiB bufreader#8869
Merged
sylvestre merged 2 commits intouutils:mainfrom Oct 20, 2025
Merged
Conversation
Contributor
|
please run hyperfine with the three commands |
sylvestre
reviewed
Oct 10, 2025
| use uucore::translate; | ||
|
|
||
| const NAME: &str = "hashsum"; | ||
| const READ_BUFFER_SIZE: usize = 32 * 1024; |
Contributor
There was a problem hiding this comment.
please add an comment explaining what is this magic number
(like GNU is fine)
|
GNU testsuite comparison: |
833e079 to
6220e13
Compare
6220e13 to
4817e3b
Compare
|
GNU testsuite comparison: |
4817e3b to
1876d0d
Compare
|
GNU testsuite comparison: |
Contributor
Author
hyperfine results comparing main, PR and GNU |
|
GNU testsuite comparison: |
Contributor
|
both codspeed and my system don't see any difference: or |
Contributor
|
i guess it is windows specific ?! |
Contributor
Author
|
Yeah, Its the overhead from WSL. I guess we can drop this PR given that we dont see much improvement in Linux. |
Contributor
|
well, improving Windows is great |
Contributor
Author
|
Thanks for the help and merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
In my WSL environment, I found that gnu md5sum was faster than coreutils md5sum. So I investigated via strace and found that GNU used 32KiB size buffers while coreutils used 8KiB as shown below to read files. This PR aims to do the same, there by closing the performance gap to an extent.
md5sum
Version details
With this PR I dont much improvement when compared to main branch for smaller inputs. Its only for larger inputs that we will notice anything.
Benchmarks when compared to main
Even with this PR, I still find that GNU hashsum is still 20% faster in my system for very large inputs.
Since I am doing this with WSL, it would be nice if others could also check this patch once on there linux systems.