Zstd: Questions about ZSTD_compressBound() speed optimization

Created on 24 Sep 2020  路  2Comments  路  Source: facebook/zstd

I have two questions about ZSTD_compressBound() speed optimization, hope to get your answer.

1, It seems ZSTD_compressBound() speed optimization only works for ZSTD_e_end end directive (in both single-threaded and multi-threaded compression), is this right?

2, Is it possible to support ZSTD_e_continue / ZSTD_e_flush mode in the future?

Thanks

question

Most helpful comment

1, It seems ZSTD_compressBound() speed optimization only works for ZSTD_e_end end directive (in both single-threaded and multi-threaded compression), is this right?

That is correct.

2, Is it possible to support ZSTD_e_continue / ZSTD_e_flush mode in the future?

No, it is not possible. The optimization works because when you pass ZSTD_e_end with output size >= ZSTD_compressBound() zstd knows that it has all of the input, and is guaranteed to have enough space to finish the compression.

The optimization avoids copying the input into zstd's internal buffer. When ZSTD_e_continue or ZSTD_e_flush are passed, zstd must copy the input into an internal buffer, because it needs to continue to reference it in future calls to ZSTD_compressStream2().

All 2 comments

1, It seems ZSTD_compressBound() speed optimization only works for ZSTD_e_end end directive (in both single-threaded and multi-threaded compression), is this right?

That is correct.

2, Is it possible to support ZSTD_e_continue / ZSTD_e_flush mode in the future?

No, it is not possible. The optimization works because when you pass ZSTD_e_end with output size >= ZSTD_compressBound() zstd knows that it has all of the input, and is guaranteed to have enough space to finish the compression.

The optimization avoids copying the input into zstd's internal buffer. When ZSTD_e_continue or ZSTD_e_flush are passed, zstd must copy the input into an internal buffer, because it needs to continue to reference it in future calls to ZSTD_compressStream2().

I see, thank you for your answer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

escalade picture escalade  路  3Comments

AbdulrahmanAltabba picture AbdulrahmanAltabba  路  3Comments

TheSil picture TheSil  路  3Comments

scherepanov picture scherepanov  路  3Comments

pjebs picture pjebs  路  3Comments