Question: Reuse of Compressor/Decompressor
bill-poole opened this issue · 2 comments
Firstly, I'd like to thank you for creating this excellent library.!
I'm doing compression/decompression in a high performance environment, and as such I want to reuse each Compressor
/Decompressor
object to compress/decompress many streams because there is an overhead with creating/initializing the Compressor
/Decompressor
objects. However, the library is throwing an exception saying the input Zstandard is corrupt if I reuse a single Decompressor
object across multiple threads concurrently.
I couldn't find any documentation saying whether the Compressor
and Decompressor
objects are thread-safe. I assume based on the errors I'm getting that they are not. Is that correct? If so, do you recommend creating an instance of each per thread (using a [ThreadStatic]
attribute?
Apologies if this is documented somewhere and I missed it.
It's just like the original zstd library, you need a different Compressor/Decompressor
object for each thread.
https://facebook.github.io/zstd/zstd_manual.html#Chapter4
Ah, excellent, thanks for pointing me to the relevant documentation.