compression: use zstd,-4 as the new default - #10100
Draft
ThomasWaldmann wants to merge 1 commit into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10100 +/- ##
=======================================
Coverage 87.03% 87.04%
=======================================
Files 101 101
Lines 17730 17742 +12
Branches 2678 2680 +2
=======================================
+ Hits 15432 15444 +12
+ Misses 1598 1597 -1
- Partials 700 701 +1 ☔ View full report in Codecov by Harness. |
ThomasWaldmann
marked this pull request as draft
August 14, 2026 14:03
ThomasWaldmann
force-pushed
the
zstd-default-10085
branch
from
August 14, 2026 22:36
1af91c8 to
cdbfa5e
Compare
lz4 -> zstd,-4 for the -C default of create, recreate, import-tar, transfer, repo-compress and debug put-obj. Benchmarked on real data (see PR): end-to-end create is as fast as or faster than lz4 on small-file-heavy and binary corpora - libzstd's multithreading (chunks >= 768 KiB) more than makes up for lz4's higher single-thread speed on small chunks - at the same or slightly smaller repo size. lz4 stays available, nothing changes for existing repos. Also: zstd,-4 added to the borg benchmark cpu codec list, docs updated, usage/man files regenerated for the affected commands. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ThomasWaldmann
force-pushed
the
zstd-default-10085
branch
from
August 14, 2026 22:40
cdbfa5e to
b9da5fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
zstd,-4the default compression forcreate,recreate,import-tar,transfer,repo-compressanddebug put-obj(previouslylz4). Fixes #10085.Why zstd,-4
Benchmarked on ~45 GB of real data on an M3 Pro (12 cores), with the default chunker (fastcdc, ~2 MiB target) and the current default of 4 zstd MT workers per chunk. Measured both at the compressor level (chunks fed to the compressor exactly as borg produces them) and end-to-end via
borg create/borg extract. Corpora:.git(7.6 GB, 250k chunks, 44% of bytes in small chunks < 768 KiB, i.e. no MT)Compressor level, byte-weighted (size = % of lz4's compressed size, lower is better):
On small chunks alone (single-threaded) lz4 keeps a slight edge; big chunks flip it, as libzstd's threads engage from 768 KiB up. On the VM image lz4 stays ahead at every negative level: that image is dominated by long, easy repeats which lz4 races through at ~8 GB/s, and no zstd level changes this (they all land within 0.70x..0.74x) because the level only steers match search, which is not the limit there.
End-to-end, median of 3 interleaved iterations, fresh repo per run,
-e none-blake3:createwith zstd,-4 is faster than lz4 on both file-tree corpora (2% on code, 5% on binaries), a tie on incompressible data, and 11% slower on the VM image - at the same or smaller repo size everywhere.extractis 5-6% slower on the tree corpora (lz4 decompresses faster in isolation, though restore is not decompression-bound) and 6% faster on the VM image.That matches the goal in #10085: as fast as or faster than lz4 in the common cases, MT for large chunks, good small-chunk speed, and slightly better compression thrown in. Users who back up mostly hard-to-compress images can keep lz4's edge there with
-C lz4,-C auto,zstd,-4or-C none.Why this level: levels below -4 buy no end-to-end speed at all (create is flat from -10 to -1, within ~2%) and only cost repo size - zstd,-10 stores 12% more than lz4 on code. Levels above -4 shrink repos further at unchanged create time, and positive levels cost real time (zstd,3: +4% create on code, +6% on binaries, +58% on entropy).
zstd,-4is the speed-first choice, as suspected in #10085;zstd,-2is the ratio-leaning alternative at the same create time (repos 5-6% smaller) if that trade is preferred.The entropy corpus also shows what the negative levels give up: they skip literal entropy coding, so data that only an entropy coder can shrink stays uncompressed for them (as for lz4), while zstd,3 halves it.
Verified functionally: after
borg createwithout-C, aborg repo-compress -C zstd,-4 --statsrun reports all compressible objects as "already had the desired compression".Changes
-Cargparse defaults:lz4->zstd,-4borg help compression: default moved from the lz4 entry to zstdborg benchmark cpu:zstd,-4added to the compressor listTests
No test asserted the default spec; the one stale comment mentioning it was updated. CI is green; locally 2505 tests pass and the failures that remain reproduce identically on unmodified master in the same environment.
🤖 Generated with Claude Code