feat(rust): port compression-parameter selection
Move the context-free compression-parameter logic of zstd_compress.c to rust/src/zstd_compress_params.rs: the compression-level tables (formerly clevels.h), parameter bounds/checking/clamping, cycle log, level-table selection, source/dictionary parameter adjustment, default frame parameters, and the match-state/CDict size estimators. The boundary follows the module's design notes: Rust owns only leaves whose behavior is independent of C preprocessor configuration. C keeps the public ZSTD_* symbols and feeds the leaves everything that is configuration-owned as explicit scalars: - The ZSTD_EXCLUDE_*_BLOCK_COMPRESSOR strategy cascade stays in ZSTD_adjustCParams_internal() ahead of the Rust adjustment leaf, so reduced builds keep their fallback policy. - Workspace estimation receives struct sizes (ZSTD_CDict, ZSTD_match_t, ZSTD_optimal_t), HUF workspace size, and the sanitizer redzone size, because those depend on private layouts and ASAN configuration. - ZSTD_cParam_getBounds() forwards only the compression level and the seven core parameters; all other parameter bounds remain C. - Frozen private constants the leaves hardcode (short-cache and row-hash tag widths, MaxML/MaxLL/MaxOff/Litbits, ZSTD_OPT_SIZE, cwksp alignment) are pinned by ZSTD_STATIC_ASSERTs at the C call sites. Two latent 32-bit bugs in the previously unwired module were fixed before integration: dictAndWindowLog's max window size and the window-resize threshold were hardcoded to the 64-bit constants (1<<31, 1<<30) instead of deriving from ZSTD_WINDOWLOG_MAX, which is 30 on 32-bit targets. clevels.h is no longer included anywhere but stays in-tree as the reference for mechanical comparison against the Rust table. Test plan: - cd rust && cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test --all-targets (125 tests) - make -C tests fuzzer && ./tests/fuzzer -i1 --no-big-tests - make -C tests test-rust-lib-smoke - Byte-identity: zstd CLI frames for COPYING, a 250 KB C source, and a 5 MB datagen sample at levels 1/3/9/19/--fast=5 are identical between this change and its parent commit.
This commit is contained in:
@@ -28,6 +28,8 @@ pub mod zstd_compress_frame;
|
||||
#[cfg(feature = "compression")]
|
||||
pub mod zstd_compress_literals;
|
||||
#[cfg(feature = "compression")]
|
||||
pub mod zstd_compress_params;
|
||||
#[cfg(feature = "compression")]
|
||||
pub mod zstd_compress_sequences;
|
||||
#[cfg(feature = "compression")]
|
||||
pub mod zstd_compress_superblock;
|
||||
|
||||
Reference in New Issue
Block a user