Skip to content

Conversation

@afbjorklund
Copy link
Contributor

@afbjorklund afbjorklund commented May 17, 2025

Currently this requires linking a patched or static version of the
libraries, where support for "rsyncable" compression has been added.

For zstd specifically, this also requires defining a special macro
-DZSTD_STATIC_LINKING_ONLY=1, before #include <zstd.h> (in flags).

Assuming that the static libraries have been installed under /opt:

EXTRA_CFLAGS="-I/opt/zlib/include -DZSTD_STATIC_LINKING_ONLY=1 -I/opt/zstd/include" EXTRA_LDFLAGS="-L/opt/zlib/lib -L/opt/zstd/lib" make

The original patch for zlib seems lost, but resurrected it from deltarpm
https://svn.uhulinux.hu/packages/dev/zlib/patches/02-rsync.patch

For zstd it is now included by default (since version 1.3.8), but it still a
"experimental parameter" and thus requires static linking like above.

The idea behind rsyncable is to add some "synchronization points",
using a rolling hash instead of a fixed size, to help with delta transfer.

The output format is compatible, but the extra hash makes it slower...
Thus it is not supported for lz4, and not recommended for fast zstd*.

* compression levels below 6 or so, i.e. normally used with 9 or 15

zstd.h says: "NOTE: Rsyncable mode will limit the maximum compression speed to approximately 400 MB/s. [...]"


"The rsync algorithm": https://rsync.samba.org/tech_report/

gzip -9 --rsyncable

The pigz implementation uses a faster hash, than the original gzip.

zstd -9 --rsyncable

Currently this requires linking a patched or static version of the
libraries, where support for "rsyncable" compression has been added.

For zstd specifically, this also requires defining a special macro
`-DZSTD_STATIC_LINKING_ONLY=1`, before #include <zstd.h> (in flags).

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant