feat(compress): move advanced CDict policy into Rust

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
This commit is contained in:
2026-07-19 16:53:31 +02:00
parent 35ad752b00
commit 5449a4b3c0
4 changed files with 684 additions and 57 deletions
+5 -3
View File
@@ -153,8 +153,9 @@ static-CCtx workspace validation and initialization dispatch, and public CDict
constructor parameter selection, default-level normalization, and
workspace/object teardown ordering, public static-CDict workspace validation
and initialization dispatch, public advanced-CDict one-shot validation and
begin/end ordering, public
advanced-compression parameter validation/init policy, public
begin/end ordering, advanced-CDict parameter selection, dedicated-search
fallback, row-matchfinder resolution, and create/init/failure ordering,
public advanced-compression parameter validation/init policy, public
usingDict parameter selection, dictionary-presence handling, and default-level
normalization, and public usingCDict frame-policy construction and begin/end
sequencing, legacy public CDict-begin frame-policy construction and
@@ -163,7 +164,8 @@ parameter selection and default-level normalization, and public advanced-begin
parameter validation and init-then-begin ordering now run in Rust.
CDict advanced allocation/lifecycle machinery, private static-CCtx and
static-CDict workspace construction and dictionary-content allocation/loading,
reset policy,
and advanced-CDict private workspace construction and dictionary-content
loading remain in C. Reset policy,
private CCtx/matchfinder/workspace operations, and codec/adaptive-policy
callbacks remain in C. CDict initialization ordering and scalar publication,
shared compression-begin dictionary selection, CDict reset attach-versus-copy