Repository navigation
Keep the buffer zero past its bytes - #38
Merged
Merged
Conversation
finalize wrote the marker after the buffered tail, then zeroed the rest of the block with a fill of variable length, just before the block was read to be compressed. The buffer now stays zero past its bytes instead: it starts that way, update only appends to it, and a buffer that has been compressed is zeroed whole before the next tail goes in. Padding is then the marker and the length alone. On an Apple M4, interleaved against main (5 rounds, criterion medians), every way of hashing a short message is faster, the streaming Hasher as much as the one-shot: one update and finalize 1-64 B -5.3% object-shaped, header and content 1-64 B -5.2% one-shot digest() 1-64 B -5.2% any of the three 65-512 B -0.5% to -1.3% 16 KiB throughput -0.1%
Merged
srijs
added a commit
that referenced
this pull request
Sep 28, 2026
sha1dc 0.1.5 recompresses on the SHA-1 instructions, which makes it 2–4% faster than 0.1.4 on large inputs on every machine with them: about 2% on the Apple M4, Graviton4, Sapphire Rapids and Zen, and 4% on Ice Lake. Detection now costs 16% to 22% of throughput, down from 18% to 23%. Notable changes: - A block that trips the filter is recompressed on the ARMv8 SHA-1 instructions or SHA-NI, from the boundary at step 60 or 64 in both directions, where it used to take the portable compression (#36). - The hasher keeps its buffer out of what the compression receives, and tracks the buffered bytes by the total length alone (#37). The buffer stays zero past its bytes, so finalizing writes only the 0x80 and the length (#38).
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.
finalize wrote the marker after the buffered tail, then zeroed the rest of the block with a fill of variable length, just before the block was read to be compressed. The buffer now stays zero past its bytes instead: it starts that way, update only appends to it, and a buffer that has been compressed is zeroed whole before the next tail goes in. Padding is then the marker and the length alone.
On an Apple M4, interleaved against main (5 rounds, criterion medians), every way of hashing a short message is faster, the streaming Hasher as much as the one-shot: