zstd
Prepare
Section titled “Prepare”- The
notracepatch is only for gcc 10, and is not needed with gcc 11+ as LTO works with zstd
zstdwas benchmarked withzstd -b3 -e9 -i3 $filegcc’s-O3regresses both in size and performance (up to 50% performance loss)-Osalso results in performance regressions-O2produces the best results for bothclangandgccLDFLAGScan be passed usingLDFLAGS_DYNLIB="$LDFLAGS" makenotmake LDFLAGS_DYNLIB="$LDFLAGS"as the latter removes-pthreadmake -C lib libzstdonly builds the dynamic librarymake lib-mtforce enables multithreading on both dynamic and (the removed) static libraries and it is not needed- The dynamic library is multithreaded and the static library is single-threaded by default
make -C programs zstd-dllbuildszstdas a thin wrapper around the dynamiclibzstd.solibrary that was just builtmake -C programs zstd-dlltarget produces a much smallerzstdcompared tomake zstdHASH=xxhsumuses the fasterxxhashinstead of the defaultmd5sumbut introduces a build-time only dependency onxxhashHAVE_ZLIB,HAVE_LZMAandHAVE_LZ4are only relevant forprogramsand are enabled if detected so disable them explicitlyZSTD_LIB_MINIFY=1overridesCFLAGSwith-OzifCCis set toclangwhich results in performance regressionsZSTD_NO_ASM=0is set by defaultZSTD_NOBENCH,ZSTD_NODICTandZSTD_NOTRACEare preprocessor macros that shouldn’t be passed asmakevariables- Do not override
CFLAGSto pass preprocessor macros, instead useCPPFLAGS - Do not override
CFLAGSforlibwithmake -C lib CFLAGS="$CFLAGS"as it removes-fPICand other default flags including warnings
Package
Section titled “Package”- Do not use the
make installtarget as it builds and installs the static library as well PKGCONFIGDIRcontrols where the.pcfile is installed (notPCLIBDIR)-pthreadis included inlibzstd.pcand is automatically passed when linking against it
makeis the official build system (other build systems, though compatible, are maintained by 3rd-parties)- Level
3is good enough; after level19it will regress - Prefer
zstd -T0tozstdmtandpzstdas it is more modern - Static library can be disabled with
cmake - Support for decoding legacy formats will be disabled by default (
ZSTD_LEGACY_SUPPORT=0) from1.6.0 zstdis multithreaded, faster and more widely adopted compared tobrotli
clear’sfopenpatch has an m mode (rbm) that is only forglibc
References
Section titled “References”- https://github.com/facebook/zstd/blob/dev/examples/README.md
- https://github.com/facebook/zstd/blob/dev/lib/README.md
- https://github.com/facebook/zstd/blob/dev/programs/README.md
- https://github.com/facebook/zstd/blob/dev/tests/README.md
- https://helpful.knobs-dials.com/index.php/Compression_notes
- https://peazip.github.io/fast-compression-benchmark-brotli-zstandard.html