Skip to content

Conversation

@terrelln
Copy link
Contributor

@terrelln terrelln commented Mar 7, 2023

Clarify dstCapacity requirements for single-pass functions.

Fixes #3524.

Clarify `dstCapacity` requirements for single-pass functions.

Fixes facebook#3524.
* - 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@terrelln terrelln merged commit c40c737 into facebook:dev Mar 9, 2023
@terrelln terrelln deleted the 2023-03-07-issue-3524 branch March 9, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants