Move the MT reusable-input wait decision and lock/overlap/condition-wait
ordering into Rust through a small callback projection. C retains ownership
of the pthread synchronization objects, private LDM window, and diagnostics.
Add layout assertions and callback-order tests for enabled and disabled LDM.
Test Plan:
- ulimit -v 41943040; CARGO_BUILD_JOBS=1; cargo test --manifest-path rust/Cargo.toml
- ulimit -v 41943040; CARGO_BUILD_JOBS=1; cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- ulimit -v 41943040; make -B -C programs -j1 zstd
- ulimit -v 41943040; make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
Move the bounded nextToUpdate catch-up arithmetic used after very long
matches into Rust. C continues to calculate the source index against the
private match-state window and retains all surrounding assertions and setup;
Rust owns the exact wrapping U32 threshold and 192-byte catch-up policy.
Test Plan:
- cargo fmt --manifest-path rust/Cargo.toml -- --check
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml limit_next_to_update --lib (1 passed)
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --lib (692 passed)
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- ulimit -v 41943040 && MAKEFLAGS=-j1 make -B -C programs -j1 zstd
- ulimit -v 41943040 && MAKEFLAGS=-j1 make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s (84 tests and both short fuzz rounds passed)
Move the scalar planning portion of ZSTD_resetCCtx_internal across an
explicit C/Rust boundary. Rust now computes window and block sizes, sequence
capacities, buffered I/O sizes, LDM and external-sequence reservations, the
index-reset policy, and the CCtx workspace estimate. C retains private
workspace resizing, reservations, pointer publication, and layout-dependent
callbacks.
Add ABI layout assertions and focused planner tests for buffered sizing, LDM
and index-reset policy, external sequence capacity, and invalid unadjusted LDM
inputs. Keep the migration boundary documented so the hybrid state remains
explicit while deeper CCtx reset and matchfinder operations stay in C.
Test Plan:
- `cargo fmt --manifest-path rust/Cargo.toml -- --check`
- capped focused planner tests: 3 passed
- capped full Rust library tests: 680 passed, 0 failed
- capped `cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings`: passed
- capped native `make -B -C programs -j1 zstd`: passed; only known fileio const-cast warnings
- capped `make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s`: 84 tests and both short fuzzer rounds passed; only known zstream initializer warning
The CCtx workspace estimator still assembled its private sizing formula in C,
even though the match-state and component-sum leaves already lived in Rust.
That left buffering, LDM, static-context, and external-sequence sizing policy
outside the rewrite boundary.
Move the complete size_t formula into a Rust entry point. C now supplies only
private object sizes, sanitizer redzone policy, and LDM scalar fields through a
small ABI record. Rust retains the C wrapping/alignment behavior and focused
branch coverage while the C adapter preserves the existing public estimator
surface.
Test Plan:
- cargo fmt --manifest-path rust/Cargo.toml -- --check
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --release estimate_cctx_workspace_size
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --release (667 passed)
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --release --all-targets -- -D warnings
- ulimit -v 41943040; make -B -C programs -j1 zstd
- ulimit -v 41943040; make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s (84 tests and both short fuzzer rounds)
ZSTD_createCDict_advanced2 previously selected compression parameters,
resolved dedicated-dictionary-search fallback, and ordered allocation and
initialization entirely in C. That left a large public dictionary boundary
outside the Rust rewrite and made the failure ordering implicit in the C
wrapper.
The Rust params API now owns advanced-CDict parameter preparation, including
the dedicated-search override/fallback and row-matchfinder resolution. A Rust
dictionary bridge owns the create -> init sequence and frees a created CDict
when initialization fails. The C shim retains only the private workspace and
custom-memory allocation, dictionary initialization, and teardown callbacks;
opaque parameter-field pointers and compile-time layout assertions preserve
the existing ABI. Focused probes cover policy publication and all callback
failure-ordering paths, and the migration README records the remaining C
boundary.
Test Plan:
- `rustfmt --check` and `cargo fmt --manifest-path rust/Cargo.toml -- --check` -- passed
- `cargo test --manifest-path rust/Cargo.toml --release` -- 663 passed
- `cargo clippy --manifest-path rust/Cargo.toml --release --all-targets -- -D warnings` -- passed
- `make -B -C programs -j1 zstd` -- passed
- `make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s` -- 84 tests and both fuzz rounds passed
Record that Rust now owns advanced CDict one-shot validation and begin/end
ordering while C retains the private operations behind callbacks.
Test Plan:
- Documentation-only change; code validation is covered by 8b783e8.
Record that Rust now owns static CCtx workspace validation and dispatch while
C retains private workspace construction and context initialization.
Test Plan:
- Documentation-only change; code validation is covered by 463ceeb86.
Record that Rust now owns static CDict workspace validation and dispatch while
C retains private workspace construction and dictionary initialization.
Test Plan:
- Documentation-only change; code validation is covered by 12b99469b.
Record that Rust now owns CDict null handling and workspace/object teardown
ordering while C retains private workspace and allocator callbacks.
Test Plan:
- Documentation-only change; code validation is covered by 14157558f.
Record that Rust now owns regular and by-reference CDict constructor parameter
selection and default-level normalization while C retains advanced allocation
and workspace lifecycle.
Test Plan:
- Documentation-only change; code validation is covered by 9f4d92808.
Record that Rust now owns public CCtx allocation validation and
allocate-before-init ordering while C retains private context initialization.
Test Plan:
- Documentation-only change; code validation is covered by aa817a56b.
Record that Rust now owns the legacy CDict-begin fixed frame policy and
unknown-source pledge while C retains the private begin callback.
Test Plan:
- Documentation-only change; code validation is covered by 2fdd548a3.
Record that Rust now owns public advanced-begin parameter validation and
init-then-begin ordering while C retains private context initialization and
begin callbacks.
Test Plan:
- Documentation-only change; code validation is covered by feee05372.
Record that Rust now owns the compressBegin_usingDict family’s unknown-source
parameter selection and default-level normalization while C retains the private
begin callback.
Test Plan:
- Documentation-only change; code validation is covered by 9c0b9bd25.
Record that Rust now owns the public usingCDict fixed-frame policy and
begin/end sequencing while C retains the private CDict compression callbacks.
Test Plan:
- Documentation-only change; code validation is covered by 0fbc9ff37.
Record that Rust now owns the public usingDict parameter-selection,
dictionary-presence, and default-level policy while C retains private context
initialization and compression callbacks.
Test Plan:
- Documentation-only change; code validation is covered by 556cdc53b.
Record that Rust now owns public advanced-compression parameter validation and
initialization ordering while C retains private context setup and execution.
Test Plan:
- git diff --cached --check
Record that Rust now owns public CCtx-copy pledge and frame-parameter policy,
while C retains the private workspace and table-copy operation.
Test Plan:
- git diff --cached --check
Move public ZSTD_copyCCtx pledge normalization and frame-parameter policy into
Rust while retaining the private workspace and match-table copy implementation
behind a C callback.
Test Plan:
- cargo test --manifest-path rust/Cargo.toml --lib
- cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- make -B -C programs -j1 zstd
- make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
- focused copy_cctx unit tests
Record that Rust now selects the CDict attach-versus-copy reset path while C
retains the workspace- and match-state-heavy reset operations.
Test Plan:
- git diff --cached --check
Move the shared CDict attach-versus-copy policy and callback dispatch into a
Rust-owned ABI leaf. Keep both workspace- and match-state-heavy reset
implementations in C behind opaque callbacks.
Test Plan:
- cargo test --manifest-path rust/Cargo.toml --lib
- cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- make -B -C programs -j1 zstd
- make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
- focused reset_using_cdict unit tests
Record that shared compression-begin dictionary selection now runs in Rust,
while C retains the reset, attach, and private dictionary operation callbacks.
Test Plan:
- git diff --cached --check
Clarify that CDict initialization ordering and scalar publication now run in
Rust, while allocation, private dictionary loading, and match/workspace
callbacks remain C-owned.
Test Plan:
- git diff --cached --check
Move shared CDict initialization ordering and scalar publication into a
Rust-owned ABI leaf used by both dynamic and static CDict creation. Keep
content allocation/copy, entropy workspace reservation, match-state reset,
and dictionary insertion behind narrow C callbacks so private CDict and
workspace layouts remain C-owned.
Test Plan:
- cargo test --manifest-path rust/Cargo.toml --lib
- cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- make -B -C programs -j1 zstd
- make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
- focused cdict_init unit test
Record that Rust now owns external-producer invocation and successful-path
validation plus external raw-sequence-store reset, while C retains private
transfer, fallback, and context operations.
Test Plan:
- git diff --cached --check
Move the mutable external raw-sequence-store assignment and cursor reset
behind a Rust-owned pointer projection. Keep the public C entry point and
its stage/LDM assertions in C, without exposing RawSeqStore_t to Rust.
Test Plan:
- cargo test --manifest-path rust/Cargo.toml --lib
- cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- make -B -C programs -j1 zstd
- make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
- focused reference_external_sequences unit tests