borgbackup/scripts
Thomas Waldmann f2b96e3d15
fastcdc: add FastCDC chunker with a keyed Gear hash
Add a new "fastcdc" content-defined chunker selectable via --chunker-params.
It uses the FastCDC Gear rolling hash (fp = (fp << 1) + Gear[byte]), which is
window-less and cheaper per byte than buzhash's cyclic-polynomial update, so it
chunks noticeably faster (see "borg benchmark cpu" output), while producing
the same chunk-size distribution and deduplication.

The Gear table is keyed: it is derived from the repo id key via CSPRNG (own
"fastcdc" domain), exactly like the buzhash64 table, so chunk cut points stay
unpredictable without the key (anti-fingerprinting). It implements the same
FastCDC techniques as buzhash64 (sub-minimum skipping, normalized chunking with
a required nc_level, min/max clamping); the mask uses the high bits of the hash
(Gear accumulates entropy there).

chunker-params: "fastcdc,chunk_min,chunk_max,chunk_mask,nc_level" - there is no
window field, because Gear is window-less. e.g. fastcdc,19,23,21,2

Also: borg benchmark cpu now measures the fastcdc chunker; tests in
borg.testsuite.chunkers (golden vector, size distribution, keyed gear table,
param parsing, slow fuzz); docs and changelog.

Benchmarks (scripts/chunker_bench.py, buzhash64 vs fastcdc, both nc_level=2,
incompressible data unless noted):

  5 GiB, 2 MiB target (default params):
    buzhash64: CV 0.294, 1011 MB/s
    fastcdc:   CV 0.295, 1313 MB/s   (+30%)

  64 MiB, 64 KiB target:
    buzhash64: CV 0.374, shift-resilience 0.9928,  963 MB/s
    fastcdc:   CV 0.359, shift-resilience 0.9929, 1331 MB/s   (+38%)

  Re-backup of a 2.5 GiB file after scattered single-byte edits (dedup ratio,
  0.5 = v2 fully deduplicated, lower is better):
     64 edits:  buzhash64 0.5237, fastcdc 0.5236
    320 edits:  buzhash64 0.6133, fastcdc 0.6161

  borg benchmark cpu, 1 GB: fastcdc 3.80s, buzhash 4.36s, buzhash64 8.13s,
  fixed 0.56s.

Chunk-size distribution, deduplication and shift-resilience match buzhash64
within noise; fastcdc is consistently faster.

Also: fix bug when computing the mask, one needs to use 1ULL instead of
1, so the shifting computation is done in a uint64, not in a 32bit int.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 23:24:25 +02:00
..
make-testdata fixed typos and grammar (AI) 2025-09-23 14:56:23 +02:00
shell_completions/fish create: add --exclude-dataless to skip cloud files not materialized locally 2026-06-11 07:36:53 +02:00
borg.exe.spec pyinstaller binary: do not exclude ssl, needed for pyfuse3/trio, fixes #9196 2026-02-14 19:32:38 +01:00
build-borg-using-nuitka.sh binary build scripts: use /bin/sh 2026-06-07 15:32:19 +02:00
build-borg-using-pyinstaller.sh binary build scripts: use /bin/sh 2026-06-07 15:32:19 +02:00
chunker_bench.py fastcdc: add FastCDC chunker with a keyed Gear hash 2026-07-01 23:24:25 +02:00
Dockerfile.linux-run use xxhash from PyPI, fixes #6535 2026-03-08 13:06:01 +01:00
errorlist.py fixed typos and grammar (AI) 2025-09-23 14:56:23 +02:00
fetch-binaries build binaries on github 2025-10-16 00:37:46 +02:00
glibc_check.py fixed typos and grammar (AI) 2025-09-23 14:56:23 +02:00
linux-run rename Dockerfile to match script name 2026-02-14 19:32:32 +01:00
make.py docs: add docs for "key add", "key list" and "key remove" 2026-06-13 21:37:21 +02:00
msys2-install-deps remove xxhash / xxh64 requirement, mentions 2026-06-10 00:38:18 +02:00
sdist-sign use less setup.py, use pip and build 2024-01-02 19:50:59 +01:00
sign-binaries fix shellcheck warnings in bash scripts 2022-07-22 15:52:04 +00:00
upload-pypi upload-pypi: use borg-specific repository names 2025-11-01 19:57:26 +01:00