feat(compress): move advanced CDict allocation policy into Rust

The advanced CDict bridge previously left custom-memory validation,
workspace allocation, and create/init failure ordering inside one C helper.
That made the Rust policy seam stop before allocation and obscured which
allocation owned cleanup after private CDict construction failed.

Move validation, workspace-size query dispatch, allocation, and cleanup
ordering into the Rust bridge. C retains the private workspace-size formula,
workspace/object placement, allocator callbacks, and CDict initialization.
The focused probes cover invalid allocators, allocation failure, creation
failure, and initialization failure with exact callback ordering.

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 create_cdict_advanced
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --release (665 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)
This commit is contained in:
2026-07-19 17:10:08 +02:00
parent 5449a4b3c0
commit e6101bb1af
3 changed files with 354 additions and 69 deletions
+5 -3
View File
@@ -162,10 +162,12 @@ sequencing, legacy public CDict-begin frame-policy construction and
unknown-source pledge, and the compressBegin_usingDict familys unknown-source
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
CDict advanced private workspace construction, private static-CCtx and
static-CDict workspace construction and dictionary-content allocation/loading,
and advanced-CDict private workspace construction and dictionary-content
loading remain in C. Reset policy,
and advanced-CDict dictionary-content loading remain in C. Rust now owns
advanced-CDict custom-memory validation, workspace-size query/allocation, and
allocation/create/init cleanup ordering; C retains the private workspace
size formula, layout, and allocator callbacks. 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