feat(compress): move dedicated dict hash-log transforms to Rust

Keep dedicated-dictionary strategy dispatch, parameter selection, and call-site
control flow in C while routing only the hashLog field transformations through
scalar Rust ABI helpers. The helpers use wrapping u32 arithmetic so overflow
and the existing subtract-then-clamp behavior remain identical to C.

Test Plan:
- `cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression dedicated_dict_search_hash_log_adjustments_match_strategy_cases` -- passed
- `make -B -C lib -j2 lib` -- passed
- `make -C tests -j2 fuzzer` -- passed
- `./tests/fuzzer -s4560 -t47 -i48 -v` -- passed
- clippy normal, benches, and tests before and after formatting -- passed
- `cargo +nightly fmt --manifest-path rust/Cargo.toml` and `git diff --check` -- passed
This commit is contained in:
2026-07-18 09:13:36 +02:00
parent c86d18be81
commit ae9667052a
2 changed files with 84 additions and 5 deletions
+4 -5
View File
@@ -122,6 +122,8 @@ int ZSTD_rust_params_resolveEnableLdm(
int ZSTD_rust_params_resolveExternalRepcodeSearch(int mode, int cLevel);
int ZSTD_rust_params_cdictIndicesAreTagged(ZSTD_compressionParameters cParams);
int ZSTD_rust_params_dedicatedDictSearchIsSupported(ZSTD_compressionParameters cParams);
U32 ZSTD_rust_params_dedicatedDictSearch_getHashLog(U32 hashLog);
U32 ZSTD_rust_params_dedicatedDictSearch_revertHashLog(U32 hashLog);
/* CCtx parameter state is mirrored by rust/src/zstd_compress_params_api.rs.
* Rust owns parameter bounds and clamping; C exposes only the
@@ -5663,7 +5665,7 @@ static ZSTD_compressionParameters ZSTD_dedicatedDictSearch_getCParams(int const
case ZSTD_greedy:
case ZSTD_lazy:
case ZSTD_lazy2:
cParams.hashLog += ZSTD_LAZY_DDSS_BUCKET_LOG;
cParams.hashLog = ZSTD_rust_params_dedicatedDictSearch_getHashLog(cParams.hashLog);
break;
case ZSTD_btlazy2:
case ZSTD_btopt:
@@ -5688,10 +5690,7 @@ static void ZSTD_dedicatedDictSearch_revertCParams(
case ZSTD_greedy:
case ZSTD_lazy:
case ZSTD_lazy2:
cParams->hashLog -= ZSTD_LAZY_DDSS_BUCKET_LOG;
if (cParams->hashLog < ZSTD_HASHLOG_MIN) {
cParams->hashLog = ZSTD_HASHLOG_MIN;
}
cParams->hashLog = ZSTD_rust_params_dedicatedDictSearch_revertHashLog(cParams->hashLog);
break;
case ZSTD_btlazy2:
case ZSTD_btopt: