Skip to content

Document compatibility and determinism guarantees in zstd.h - #5075

Merged
terrelln merged 1 commit into
meta:devfrom
terrelln:2026-11-30-determinism
Dec 2, 2026
Merged

terrelln merged 1 commit into
meta:devfrom
terrelln:2026-11-30-determinism

Conversation

@terrelln

Copy link
Copy Markdown
Contributor

Add "Compatibility" and "Determinism" sections to the header, after the Introduction:

  • Compatibility: backward compatibility (every decompressor decodes data from any v1.0+ compressor, indefinitely), forward compatibility (every v1.x decompressor decodes data from any v1.x compressor), the conditions on those guarantees, a pointer to doc/decompressor_errata.md, and the position on third-party implementations of RFC 8878.
  • Determinism: what compressor output does and does not depend on, and the limits of the guarantee (version, parameters, nbWorkers == 0 vs >= 1, streaming directives, dictionaries and prefixes).

Regenerate doc/zstd_manual.html.

Fixes #4466

@Cyan4973

Copy link
Copy Markdown
Contributor

Thanks, this will be a useful reference.

Note that three statements promise a bit more than zstd guarantees today:

1. Backward compatibility. "Every zstd decompressor can decode any frame produced by any zstd compressor from v1.0 onward" is a bit broader than backward compatibility: it also covers old decompressors decoding frames from newer compressors. Suggestion, which sticks to backward compatibility: "Every zstd decompressor can decode frames produced by any earlier zstd compressor, back to v1.0."

2. 32-bit vs 64-bit. Since v1.6.0, the compressed output can depend on the architecture in multi-threaded mode with windowLog >= 27 (level 22, for example). ZSTDMT_JOBLOG_MAX is 28 on 32-bit and 30 on 64-bit, so the default job size is 256 MB on 32-bit and 512 MB on 64-bit, and inputs larger than 256 MB are split differently. This affects our own win32 and win64 release binaries. This case should be listed in the limits.

3. CDicts created by reference. The buffer-placement issue described for prefixes also applies to ZSTD_createCDict_byReference(), and ZSTD_c_deterministicRefPrefix does not cover it: see #4738, and the fix proposed in #4739. On dev, the same 256 KB input compressed with the same by-reference CDict gives different output at levels 3 and 19, depending on whether the input directly follows the dictionary in memory, with or without ZSTD_c_deterministicRefPrefix. Either the doc mentions this case, or #4739 lands first.

Also, #4671 (opened in May, not reviewed) proposes a determinism document for the same issue, #4466. It can be closed once this PR is merged.

@terrelln
terrelln force-pushed the 2026-11-30-determinism branch from 943e125 to 0c9c06f Compare December 1, 2026 20:03
@terrelln

terrelln commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author
  1. Fixed
  2. I've updated the wording to not provide any guarantees of determinsim between 32-bit and 64-bit builds. We could provide guarantees here, especially in single-threaded compression, but since we don't currently test it I didn't want to provide it.
  3. I've merged Apply ZSTD_c_deterministicRefPrefix to ZSTD_createCDict_byReference , ensure deterministic output. #4739.

@Cyan4973 Cyan4973 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all points addressed. LGTM.

One small nit: --long alone uses windowLog 27, which the default limit accepts. The example could be --long=31.

Add "Compatibility" and "Determinism" sections to the header, after the
Introduction:

* Compatibility: backward compatibility (every decompressor decodes data
  from any v1.0+ compressor, indefinitely), forward compatibility (every
  v1.x decompressor decodes data from any v1.x compressor), the
  conditions on those guarantees, a pointer to
  doc/decompressor_errata.md, and the position on third-party
  implementations of RFC 8878.
* Determinism: what compressor output does and does not depend on, and
  the limits of the guarantee (version, parameters, nbWorkers == 0 vs >= 1,
  streaming directives, dictionaries and prefixes).

Regenerate doc/zstd_manual.html.
@terrelln
terrelln force-pushed the 2026-11-30-determinism branch from 0c9c06f to 674004a Compare December 2, 2026 20:36
@terrelln
terrelln merged commit a6e4045 into meta:dev Dec 2, 2026
113 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.

[docs] Document Determinism Properties

2 participants