feat(compress): move reduce-index policy into Rust
Move match-table selection and btlazy2 marker policy out of the C overflow correction wrapper. Rust now decides whether chain and hash3 tables participate using the strategy, row-matchfinder, dedicated-dictionary, and log inputs, then delegates cell updates to the existing Rust reducer. C retains only the private table pointers and scalar projection. 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::reduce_index_for_match_state -- --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:
@@ -656,6 +656,12 @@ void ZSTD_rust_reduceIndex(U32* hashTable, U32 hashSize,
|
||||
U32* chainTable, U32 chainSize,
|
||||
U32* hashTable3, U32 hashSize3,
|
||||
U32 reducerValue, int preserveChainMark);
|
||||
void ZSTD_rust_reduceIndexForMatchState(
|
||||
U32* hashTable, U32 hashLog,
|
||||
U32* chainTable, U32 chainLog,
|
||||
U32* hashTable3, U32 hashLog3,
|
||||
int strategy, int useRowMatchFinder, int dedicatedDictSearch,
|
||||
U32 reducerValue);
|
||||
typedef int (*ZSTD_rust_overflowNeedCorrection_f)(
|
||||
void* context, const void* src, const void* srcEnd);
|
||||
typedef U32 (*ZSTD_rust_overflowCorrect_f)(
|
||||
@@ -4803,27 +4809,12 @@ size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx, unsigned long
|
||||
* rescale all indexes to avoid future overflow (indexes are U32) */
|
||||
static void ZSTD_reduceIndex (ZSTD_MatchState_t* ms, ZSTD_CCtx_params const* params, const U32 reducerValue)
|
||||
{
|
||||
U32 const hSize = (U32)1 << params->cParams.hashLog;
|
||||
U32* chainTable = NULL;
|
||||
U32 chainSize = 0;
|
||||
U32* hashTable3 = NULL;
|
||||
U32 hashSize3 = 0;
|
||||
|
||||
if (ZSTD_allocateChainTable(params->cParams.strategy, params->useRowMatchFinder, (U32)ms->dedicatedDictSearch)) {
|
||||
chainTable = ms->chainTable;
|
||||
chainSize = (U32)1 << params->cParams.chainLog;
|
||||
}
|
||||
|
||||
if (ms->hashLog3) {
|
||||
hashTable3 = ms->hashTable3;
|
||||
hashSize3 = (U32)1 << ms->hashLog3;
|
||||
}
|
||||
|
||||
ZSTD_rust_reduceIndex(ms->hashTable, hSize,
|
||||
chainTable, chainSize,
|
||||
hashTable3, hashSize3,
|
||||
reducerValue,
|
||||
params->cParams.strategy == ZSTD_btlazy2);
|
||||
ZSTD_rust_reduceIndexForMatchState(
|
||||
ms->hashTable, params->cParams.hashLog,
|
||||
ms->chainTable, params->cParams.chainLog,
|
||||
ms->hashTable3, ms->hashLog3,
|
||||
params->cParams.strategy, params->useRowMatchFinder,
|
||||
ms->dedicatedDictSearch, reducerValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user