refactor(compress): move LDM parser threshold to Rust

Move the scalar policy that selects the optimal parser for long-distance
matching into Rust.  The C implementation continues to own match-state and
compressor dispatch, but the strategy threshold is now defined and tested at
the Rust seam.

Test Plan:
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo +nightly 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 --all-targets (775 passed)
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/cli/Cargo.toml --all-targets (179 passed)
- ulimit -v 41943040; make -j1
- ulimit -v 41943040; make -j1 -C tests test (all tests completed successfully)
This commit is contained in:
2026-07-20 06:21:22 +02:00
parent 9cfbb7bebb
commit 25428b8cef
2 changed files with 17 additions and 4 deletions
+2 -2
View File
@@ -267,7 +267,7 @@ void ZSTD_rust_ldm_skipSequences(void* rawSeqStore, size_t srcSize, U32 minMatch
void ZSTD_rust_ldm_skipRawSeqStoreBytes(void* rawSeqStore, size_t nbBytes);
size_t ZSTD_rust_ldm_blockCompress(
void* rawSeqStore, void* blockContext, void* seqStore, U32 rep[ZSTD_REP_NUM],
const void* src, size_t srcSize, U32 minMatch, int useOptimalParser);
const void* src, size_t srcSize, U32 minMatch, int strategy);
U32 ZSTD_rust_ldm_limitTableUpdate(U32 curr, U32 nextToUpdate);
const U64* ZSTD_ldm_rust_gearTable(void);
@@ -406,5 +406,5 @@ size_t ZSTD_ldm_blockCompress(RawSeqStore_t* rawSeqStore,
assert(context.blockCompressor != NULL);
return ZSTD_rust_ldm_blockCompress(
rawSeqStore, &context, seqStore, rep, src, srcSize,
ms->cParams.minMatch, ms->cParams.strategy >= ZSTD_btopt);
ms->cParams.minMatch, (int)ms->cParams.strategy);
}