feat(compress): move advanced CDict sizing arithmetic into Rust
Move the advanced-CDict workspace-size formula and its by-reference, by-copy, row-match-finder, and dedicated-search branches into the Rust compression-parameter layer. Keep private C layout constants and the already-resolved mode at the C boundary, where the allocator still owns private object layout details. Add a focused test covering the load-method and dedicated-search deltas and the exported advanced-sizing boundary. Test Plan: - ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml - 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-zstream ZSTREAM_TESTTIME=-T2s - ulimit -v 41943040 && make -j1 -C tests test-fuzzer FUZZERTEST=-T3s FUZZER_FLAGS=--no-big-tests - ulimit -v 41943040 && cargo fmt --manifest-path rust/Cargo.toml -- --check - git diff --check
This commit is contained in:
@@ -1818,6 +1818,10 @@ typedef struct {
|
||||
size_t ZSTD_rust_params_estimateCDictSizeFromCParams(
|
||||
size_t dictSize, ZSTD_compressionParameters cParams,
|
||||
int dictLoadMethod, const ZSTD_rustCDictSizing* sizing);
|
||||
size_t ZSTD_rust_params_estimateCDictWorkspaceSize(
|
||||
size_t dictSize, ZSTD_compressionParameters cParams,
|
||||
int dictLoadMethod, int useRowMatchFinder,
|
||||
int enableDedicatedDictSearch, const ZSTD_rustCDictSizing* sizing);
|
||||
|
||||
/* Sequence statistics and seqStore entropy compression live in Rust
|
||||
* (rust/src/zstd_compress_stats.rs), which also exports ZSTD_seqToCodes()
|
||||
@@ -6681,14 +6685,19 @@ static size_t ZSTD_rust_createCDictAdvanced_workspaceSize(
|
||||
{
|
||||
(void)context;
|
||||
if (cParams == NULL) return 0;
|
||||
return ZSTD_cwksp_alloc_size(sizeof(ZSTD_CDict))
|
||||
+ ZSTD_cwksp_alloc_size(HUF_WORKSPACE_SIZE)
|
||||
+ ZSTD_sizeof_matchState(cParams,
|
||||
(ZSTD_ParamSwitch_e)useRowMatchFinder,
|
||||
enableDedicatedDictSearch,
|
||||
/* forCCtx */ 0)
|
||||
+ (dictLoadMethod == ZSTD_dlm_byRef ? 0
|
||||
: ZSTD_cwksp_alloc_size(ZSTD_cwksp_align(dictSize, sizeof(void*))));
|
||||
{ ZSTD_rustCDictSizing const sizing = {
|
||||
sizeof(ZSTD_CDict),
|
||||
HUF_WORKSPACE_SIZE,
|
||||
ZSTD_HASHLOG3_MAX,
|
||||
sizeof(ZSTD_match_t),
|
||||
sizeof(ZSTD_optimal_t),
|
||||
ZSTD_RUST_ASAN_REDZONE_SIZE
|
||||
};
|
||||
return ZSTD_rust_params_estimateCDictWorkspaceSize(
|
||||
dictSize, *cParams, dictLoadMethod,
|
||||
useRowMatchFinder, enableDedicatedDictSearch,
|
||||
&sizing);
|
||||
}
|
||||
}
|
||||
|
||||
static void* ZSTD_rust_createCDictAdvanced_allocate(
|
||||
|
||||
Reference in New Issue
Block a user