Yifan Cai created CASSANDRA-21677:
-------------------------------------
Summary: Pool Native Zstd Contexts in Plain ZstdCompressor
Key: CASSANDRA-21677
URL: https://issues.apache.org/jira/browse/CASSANDRA-21677
Project: Apache Cassandra
Issue Type: Improvement
Components: Feature/Compression
Reporter: Yifan Cai
ZstdCompressorBase.compress()/uncompress() call Zstd's static one-shot helpers
(Zstd.compress, Zstd.decompress, Zstd.decompressByteArray), each of which
allocates a native ZSTD_CCtx/ZSTD_DCtx and frees it before returning, once per
chunk.
According to CASSANDRA-21672, profiling of the dictionary-compression path
found roughly 6.5% of node CPU in ZSTD_createCCtx alone at small chunk sizes,
and the same per-chunk allocation cost applies to plain, non-dictionary Zstd
compression, which is unaffected by that work. ZstdCompressor should pool a
reusable ZstdCompressCtx/ZstdDecompressCtx per compressor instance, instead of
allocating and freeing a native context on every chunk.
That said, the plain ZstdCompressor is likely less impacted by the per chunk
allocation, as it typically requires larger chunk size to achieve a good
compression ratio. The effect of per chunk allocation is more significant for
small chunks such as 4KiB.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]