Recommended sizes for input/output buffer + compressor/decompressor #326

Closed
opened 2026-01-29 20:42:02 +00:00 by claunia · 1 comment
Owner

Originally created by @andrew-aladev on GitHub (Jul 2, 2020).

Hello. zstd has the following functions available:

size_t ZSTD_CStreamInSize(void);    /**< recommended size for input buffer */
size_t ZSTD_CStreamOutSize(void);   /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block. */

size_t ZSTD_DStreamInSize(void);    /*!< recommended size for input buffer */
size_t ZSTD_DStreamOutSize(void);   /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */

It will be good to have similar functions for brotli.

For now i am using 256/64 kb for compressor and 64/256 kb for decompressor.

Originally created by @andrew-aladev on GitHub (Jul 2, 2020). Hello. zstd has the [following functions](https://github.com/facebook/zstd/blob/dev/lib/zstd.h#L778-L779) available: ```c size_t ZSTD_CStreamInSize(void); /**< recommended size for input buffer */ size_t ZSTD_CStreamOutSize(void); /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block. */ size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */ size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */ ``` It will be good to have similar functions for brotli. For now i am using `256/64 kb` for compressor and `64/256 kb` for decompressor.
Author
Owner

@eustas commented on GitHub (Aug 3, 2023):

Both encoder and decoder are just fine with any input buffer, the bigger - the better.
As for output I recommend "zero-copy" API (*TakeOutput) it already uses optimal buffer internally.

@eustas commented on GitHub (Aug 3, 2023): Both encoder and decoder are just fine with any input buffer, the bigger - the better. As for output I recommend "zero-copy" API (`*TakeOutput`) it already uses optimal buffer internally.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#326