Skip to content

cli: don't pre-split blocks with --patch-from - #5058

Merged
Cyan4973 merged 1 commit into
devfrom
cli-patch-from-no-presplit
Dec 3, 2026
Merged

Cyan4973 merged 1 commit into
devfrom
cli-patch-from-no-presplit

Conversation

@Cyan4973

Copy link
Copy Markdown
Contributor

This affects zstd --patch-from users: since v1.5.7, patches are larger than with v1.5.6. Library users are unaffected.

Problem

The pre-splitter added in v1.5.7 (#4136; bisected to a5bce4a) cuts 128 KB blocks before match finding, based on byte statistics.
With --patch-from, it makes patches 12-18% larger, at the same speed.
With --long=27 alone, on the same file, it costs only 0.4-0.75%.

Fix

In --patch-from mode, the CLI sets ZSTD_c_blockSplitterLevel to 1 (no pre-splitting), which restores the v1.5.6 block boundaries.
The post-splitter (ZSTD_c_splitAfterSequences, levels 16+) is unchanged.

Measurements

120 MB patch: concatenated zstd source tarballs up to v1.5.6 as reference, up to v1.5.7 as target, -T1. Every patch decodes back with --patch-apply.

level v1.5.6 v1.5.7 v1.6.0 this PR
-3 117780 128863 128845 111584 (-13.4%)
-9 113699 122024 121612 102470 (-15.7%)
-15 99481 · 5.3 s 107006 · 10.0 s 106934 · 9.6 s 87893 · 9.2 s (-17.8%)
-19 78881 · 9.0 s 80582 · 8.2 s 80686 · 8.3 s 71322 · 7.6 s (-11.6%)

Percentages are relative to v1.6.0; dev gives the same sizes as v1.6.0.
At -3, sizes are the same with the default thread count and with -T4.

-15 is slower since v1.5.7 because the LDM parameters now depend on the strategy (4609a40, f26cc54, 72406b7), which also improves the ratio: with this PR, patches are 5-12% smaller than with v1.5.6.

The pre-splitter (#4136, v1.5.7) makes --patch-from patches 12-18%
larger on a 120 MB patch, at the same speed.
@meta-cla meta-cla Bot added the CLA Signed label Nov 27, 2026
@Cyan4973 Cyan4973 self-assigned this Nov 27, 2026
@Cyan4973
Cyan4973 merged commit 2da2b9c into dev Dec 3, 2026
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants