oleg-st/ZstdSharp

Request: Support for long distance matching

minimalisticMe opened this issue · 4 comments

Hi,

is it possible to configure usage of long distance matching for compression?
I could find it in file

* the long distance matcher, or 0 if LDM is disabled.
but I don't see how I can configure it.
Is there something I am missing out or is it currently not possible to configure for long distance matching?

Hi,

you can use compressor.SetParameter(ZSTD_cParameter.ZSTD_c_enableLongDistanceMatching, 1);

That works, thank you very much, is this enabling long distance matching or is it also possible to set a windows log?

Reference: https://github.com/facebook/zstd/tree/dev/programs

--long[=#]: enable long distance matching with given window log (default: 27)

You can use parameters from here:
https://facebook.github.io/zstd/zstd_manual.html#Chapter5

ZSTD_c_enableLongDistanceMatching, ZSTD_c_windowLog etc

ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
This parameter is designed to improve compression ratio
for large inputs, by finding large matches at long distance.
It increases memory usage and window size.
Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
except when expressly set to a different value.
Note: will be enabled by default if ZSTD_c_windowLog >= 128 MB and
compression strategy >= ZSTD_btopt (== compression level 16+) */

Thank you very much!