feat(compress): move match-state salt update into Rust

Move the row-matchfinder hash-salt field update behind a Rust in-place leaf.
C retains the private match-state pointer and entropy field access, while Rust
owns the scalar mutation and reuses the tested salt arithmetic.

Test Plan:
- cargo fmt --manifest-path rust/Cargo.toml -- --check
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings
- ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml zstd_compress::tests::bitmix_and_hash_salt_match_the_c_arithmetic -- --nocapture
- ulimit -v 41943040 && make -j1
- ulimit -v 41943040 && make -j1 -C tests test-fuzzer FUZZERTEST=-T3s FUZZER_FLAGS=--no-big-tests
This commit is contained in:
2026-07-19 21:08:02 +02:00
parent 481a53baf8
commit 2d2214eb1d
2 changed files with 19 additions and 5 deletions
+3 -5
View File
@@ -652,6 +652,7 @@ size_t ZSTD_compressStream2_c(ZSTD_CCtx* cctx,
int ZSTD_rust_simpleCompress2Level(const void* cctx, size_t srcSize);
int ZSTD_rust_simpleCompressStream2Level(const void* cctx, size_t srcSize);
U32 ZSTD_rust_limitNextToUpdate(U32 curr, U32 nextToUpdate);
void ZSTD_rust_advanceHashSaltInPlace(U64* hashSalt, U64 hashSaltEntropy);
void ZSTD_rust_reduceIndex(U32* hashTable, U32 hashSize,
U32* chainTable, U32 chainSize,
U32* hashTable3, U32 hashSize3,
@@ -3756,10 +3757,6 @@ typedef enum {
} ZSTD_resetTarget_e;
/* Mixes in the hashSalt and hashSaltEntropy to create a new hashSalt */
static void ZSTD_advanceHashSalt(ZSTD_MatchState_t* ms) {
ms->hashSalt = ZSTD_rust_advanceHashSalt(ms->hashSalt, (U64)ms->hashSaltEntropy);
}
typedef struct {
ZSTD_MatchState_t* ms;
ZSTD_cwksp* ws;
@@ -3829,7 +3826,8 @@ static void ZSTD_rust_resetMatchState_advanceHashSalt(void* opaque)
{
ZSTD_rust_resetMatchStateContext* const context =
(ZSTD_rust_resetMatchStateContext*)opaque;
ZSTD_advanceHashSalt(context->ms);
ZSTD_rust_advanceHashSaltInPlace(
&context->ms->hashSalt, (U64)context->ms->hashSaltEntropy);
}
static void* ZSTD_rust_resetMatchState_reserve(