luben / zstd-jni

JNI binding for Zstd
Other
809 stars 165 forks source link

ZstdCompressCtx setLevel​(int level) not working as intended #225

Closed praveennish closed 2 years ago

praveennish commented 2 years ago

Hi @luben

The ZstdCompressCtx setLevel​(int level) API is not working

i set compression level using below API cctx.setLevel(this.compressionLevel)

I load dictionary using cctx.loadDict()

then I use cctx.compressByteArray() API for compression.

I observed compression ratios, and compression speed to be the same even if I vary compression Levels as 1, 6, 12, and 22 which is weird.

Please help!

luben commented 2 years ago

The compression ratio/speed is dictated primary by the dictionary for the first 128KB-2MB (depends on the level). Are the payload large enough? Also the compression dictionary is trained for specific compression level so training the dictionary for higher compression level may give you some small gains in compression ratio.

As a check, you should be able to use the zstd CLI and compare the results.

praveennish commented 2 years ago

Thanks for your quick response! That helps!