refactor(compress): move LDM fast-table policy to Rust
Move the strategy classification that decides whether LDM preparation fills fast or double-fast tables into Rust. C retains the private match-state, configuration-specific table-fill leaves, and the existing excluded-DFAST assertion. Add enum-value ABI checks plus focused tests for valid and invalid strategy classifications. Test Plan: - `ulimit -v 41943040; cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` - `ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings` - `ulimit -v 41943040; make -j1` - `ulimit -v 41943040; make -j1 -C tests test` - `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` The integrated checks ran at the combined working-tree tip under a serial 40 GiB virtual-memory limit. Standalone root Rust unit linking remains unavailable because the crate imports C-owned bridge symbols without a Cargo build/link setup.
This commit is contained in:
+14
-10
@@ -248,6 +248,8 @@ ZSTD_RUST_LDM_OFFSET_CHECK(
|
||||
|
||||
#undef ZSTD_RUST_LDM_OFFSET_CHECK
|
||||
typedef char ZSTD_rust_ldm_rep_count[(ZSTD_REP_NUM == 3) ? 1 : -1];
|
||||
typedef char ZSTD_rust_ldm_strategy_values_check[
|
||||
(ZSTD_fast == 1 && ZSTD_dfast == 2 && ZSTD_btultra2 == 9) ? 1 : -1];
|
||||
|
||||
void ZSTD_rust_ldm_adjustParameters(
|
||||
void* params, U32 windowLog, int strategy,
|
||||
@@ -270,6 +272,14 @@ size_t ZSTD_rust_ldm_blockCompress(
|
||||
const void* src, size_t srcSize, U32 minMatch, int strategy);
|
||||
U32 ZSTD_rust_ldm_limitTableUpdate(U32 curr, U32 nextToUpdate);
|
||||
|
||||
enum {
|
||||
ZSTD_RUST_LDM_FAST_TABLES_NONE = 0,
|
||||
ZSTD_RUST_LDM_FAST_TABLES_FAST = 1,
|
||||
ZSTD_RUST_LDM_FAST_TABLES_DFAST = 2
|
||||
};
|
||||
|
||||
int ZSTD_rust_ldm_fastTableKind(int strategy);
|
||||
|
||||
const U64* ZSTD_ldm_rust_gearTable(void);
|
||||
void ZSTD_ldm_rust_prepareBlock(void* blockContext, const void* anchor);
|
||||
size_t ZSTD_ldm_rust_compressLiterals(
|
||||
@@ -289,24 +299,18 @@ typedef struct {
|
||||
|
||||
static void ZSTD_rust_ldm_fillFastTables(ZSTD_MatchState_t* ms, const BYTE* end)
|
||||
{
|
||||
switch (ms->cParams.strategy) {
|
||||
case ZSTD_fast:
|
||||
switch (ZSTD_rust_ldm_fastTableKind((int)ms->cParams.strategy)) {
|
||||
case ZSTD_RUST_LDM_FAST_TABLES_FAST:
|
||||
ZSTD_fillHashTable(ms, end, ZSTD_dtlm_fast, ZSTD_tfp_forCCtx);
|
||||
break;
|
||||
case ZSTD_dfast:
|
||||
case ZSTD_RUST_LDM_FAST_TABLES_DFAST:
|
||||
#ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR
|
||||
ZSTD_fillDoubleHashTable(ms, end, ZSTD_dtlm_fast, ZSTD_tfp_forCCtx);
|
||||
#else
|
||||
assert(0);
|
||||
#endif
|
||||
break;
|
||||
case ZSTD_greedy:
|
||||
case ZSTD_lazy:
|
||||
case ZSTD_lazy2:
|
||||
case ZSTD_btlazy2:
|
||||
case ZSTD_btopt:
|
||||
case ZSTD_btultra:
|
||||
case ZSTD_btultra2:
|
||||
case ZSTD_RUST_LDM_FAST_TABLES_NONE:
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
||||
Reference in New Issue
Block a user