Implement combine function for CRC32 #359
Merged
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.
Ports this reference Rust implementation: https://lenain.info/crc32-combine-in-rust/
This PR implements a function to combine 2 CRC32-computed values (ie CRC32(A) + CRC32(B)) to produce a single CRC32 value that is equal to CRC32(A+B). For example, the combination CRC32(foo) + CRC32(bar) would be equal to CRC32(foobar).
The purpose of this function is to enable parallel checksum calculation when uploading/downloading an object across multiple parts. Using a single running checksum object that all parts must update would cause head-of-line blocking, forcing already uploaded/downloaded parts to persist in memory while waiting to update the checksum object. Instead, the combine function allows each part to have its own checksum object, which are then serially combined at the end to produce a single full object checksum.
combine_crc32takes as input CRC32 integer values that are available in botocore'sCrc32Checksumclass: https://github.com/boto/botocore/blob/d3ade36d635a2b6a89229b199234afc52f9bcf55/botocore/httpchecksum.py#L82, which will be exposed in followup PRs.Example usage of this function can be seen in a draft PR: aws/aws-cli#9660