Improve speed of std.digest.digest!(Hash, Range) on non-array ranges #7509
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.
Speed up
std.digest.digest!(Hash, Range)on non-array ranges by chunking the data. I would have liked to use something likestd.stdio.File.byChunk(ubyte[])but I didn't find anything equivalent.std.algorithm.iteration.chunkBydoesn't work for this purpose.In the below tables "old/new len 16 time" refers to the time to hash 2^^24 times a range of length 16. "Old/new len. 2^^20 time" refers to the time to hash 256 times a range of length 2^^20. While benchmarking I was surprised to discover that with the implementation prior to this PR
dmd -O -inlinewas noticeably faster thanldc2 -O3for CRC32 and every MurmurHash3 variant.ldc2 -O3
dmd -m64 -O -inline
dmd -m64 (no optimizations)