Skip to content

fuzz: compress with the advanced compression parameters (Part of #118) - #122

Merged
zcsizmadia merged 1 commit into
mainfrom
fuzz-cparams
Dec 5, 2026
Merged

zcsizmadia merged 1 commit into
mainfrom
fuzz-cparams

Conversation

@zcsizmadia

Copy link
Copy Markdown
Owner

Part of #118, the follow-up listed in #121.

What

The compress fuzz target now also sets the compression parameters added in #121, on both sides:

  • libzstd: ZSTD_CCtx_setParameter;
  • zstd-native: the StreamEncoder and Compressor setters.

The parameters:

  • ZSTD_c_strategy: 1-9;
  • hashLog, chainLog: 6-20;
  • searchLog: 1-10;
  • minMatch: 3-7;
  • targetLength: 0, small values, or powers of two up to 131072;
  • literalCompressionMode: auto, enable, disable.

Each one is left at the level's value a third of the time. The output must still be byte-identical to libzstd's, and both decoders must read it back.

Details

  • Corpus: the new cparams field comes after the dictionary in EncParams, so existing corpus entries keep their meaning; their trailing bytes now pick parameters.
  • One-shot path: it no longer requires the level's own window log, since Compressor::set_window_log exists now.
  • Limits: inputs are capped at 48 KiB from btlazy2 on, whether from the level or the strategy. Hash and chain logs are capped at 20, since bigger tables only cost time.
  • RawCCtx::set_cparams: a raw FFI setter; CParameter::Strategy can't express 0, the level's value.

Testing

  • 32 workers for 10 minutes on the EPYC host (cargo +nightly fuzz, ~3.7M inputs): no mismatch, no crash.
  • Clippy (-D warnings) and fmt pass on the fuzz crate.

The compress target now also sets the parameters added in #121:
strategy, hash, chain and search log, minimum match, target length and
literal compression mode, each left at the level's value a third of the
time, on both libzstd (ZSTD_CCtx_setParameter) and zstd-native
(StreamEncoder and Compressor setters). The new field comes after the
dictionary in EncParams, so existing corpus entries keep their meaning.

The one-shot path no longer needs the level's window log: Compressor
has set_window_log now. Inputs are capped at 48 KiB from btlazy2 on (by
level or strategy), and hash and chain logs at 20.

32 workers for 10 minutes on the EPYC host (~3.7M inputs): no
mismatch, no crash.
@zcsizmadia
zcsizmadia merged commit be98248 into main Dec 5, 2026
20 checks passed
@zcsizmadia
zcsizmadia deleted the fuzz-cparams branch December 5, 2026 00:48
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