Clarify dstCapacity requirements#3531
Merged
terrelln merged 1 commit intofacebook:devfrom Mar 9, 2023
Merged
Conversation
Clarify `dstCapacity` requirements for single-pass functions. Fixes facebook#3524.
Cyan4973
reviewed
Mar 8, 2023
| * - The function is always blocking, returns when compression is completed. | ||
| * Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`. | ||
| * NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have | ||
| * enough space to successfully compress the data, though it is possible it fails for other reasons. |
Contributor
There was a problem hiding this comment.
though it is possible it fails for other reasons
What other reasons do you have in mind ?
Memory allocation failures ?
Providing dstCapacity >= ZSTD_compressBound(srcSize) should be enough to avoid #3524.
Contributor
Author
There was a problem hiding this comment.
I mean ZSTD_compress2() can let you specify a lot of options. E.g. compression could fail to allocate a thread. We could run out of memory.
I only mentioned this in ZSTD_compress2(), and skipped it in ZSTD_compress(), but I just mean that you still have to check the error code.
Cyan4973
approved these changes
Mar 9, 2023
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.
Clarify
dstCapacityrequirements for single-pass functions.Fixes #3524.