What is the upper bound of bytes added after closing a zstandard output stream?

21 views Asked by At

We are trying to prevent a zstandard compressed file from exceeding a given size limit. For this we track the number of bytes written by the compressor. We understand that when the file is closed, additional bytes may be written. What is the upper bound of the number of bytes written when a zstandard output stream is closed?

1

There are 1 answers

1
Erik van Oosten On

Experiments with random data indicate that the upper bound is 128Kb -1 +3, where 128kB is the maximum frame size, 3 is the size of a trailing empty block, and -1 because writing 128kB directly results in output (and therefore does not have to be written on close), writing 1 byte less does not result in output (and therefore needs to be written on close).

This is not a definitive answer though. For example, why is it 128kB?