feat(compress): call reset storage policy directly from Rust
The CCtx reset tail already delegated storage reservation and ordering policy to Rust, but crossed back into C through a redundant callback trampoline. Project the storage state directly through the existing pointer-sized ABI slot and invoke the Rust storage operation without the extra C hop. Keep private workspace/layout callbacks and match-state reset in C, preserve hash -> match -> storage ordering, and retain allocation-error propagation in Rust tests. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo check --manifest-path rust/Cargo.toml --tests - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040; make -j1 - ulimit -v 41943040; make -j1 -C tests test
This commit is contained in:
@@ -2304,7 +2304,7 @@ typedef struct {
|
||||
ZSTD_rust_resetCCtxStorageCallback_f resetHash;
|
||||
void* compressedBlockState;
|
||||
ZSTD_rust_resetCCtxTailCallback_f resetMatchState;
|
||||
ZSTD_rust_resetCCtxTailCallback_f resetStorage;
|
||||
const ZSTD_rust_resetCCtxStorageState* storageState;
|
||||
ZSTD_compressionParameters* matchStateCParams;
|
||||
int* matchStatePrefetchCDictTables;
|
||||
unsigned long long* pledgedSrcSizePlusOne;
|
||||
@@ -2327,7 +2327,7 @@ typedef char ZSTD_rust_reset_cctx_tail_state_layout[
|
||||
== 2 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_resetCCtxTailState, resetMatchState)
|
||||
== 3 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_resetCCtxTailState, resetStorage)
|
||||
&& offsetof(ZSTD_rust_resetCCtxTailState, storageState)
|
||||
== 4 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_resetCCtxTailState, matchStateCParams)
|
||||
== 5 * sizeof(void*)
|
||||
@@ -5389,13 +5389,6 @@ static size_t ZSTD_rust_resetCCtxTail_resetMatchState(void* opaque)
|
||||
ZSTD_resetTarget_CCtx);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_resetCCtxTail_resetStorage(void* opaque)
|
||||
{
|
||||
ZSTD_rust_resetCCtxTailContext* const context =
|
||||
(ZSTD_rust_resetCCtxTailContext*)opaque;
|
||||
return ZSTD_rust_resetCCtxStorage(context->storageState);
|
||||
}
|
||||
|
||||
/*! ZSTD_resetCCtx_internal() :
|
||||
* @param loadedDictSize The size of the dictionary to be loaded
|
||||
* into the context, if any. If no dictionary is used, or the
|
||||
@@ -5534,7 +5527,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
|
||||
tailState.resetHash = ZSTD_rust_resetCCtxTail_resetHash;
|
||||
tailState.compressedBlockState = NULL;
|
||||
tailState.resetMatchState = ZSTD_rust_resetCCtxTail_resetMatchState;
|
||||
tailState.resetStorage = ZSTD_rust_resetCCtxTail_resetStorage;
|
||||
tailState.storageState = &storageState;
|
||||
tailState.matchStateCParams = &zc->blockState.matchState.cParams;
|
||||
tailState.matchStatePrefetchCDictTables =
|
||||
&zc->blockState.matchState.prefetchCDictTables;
|
||||
|
||||
Reference in New Issue
Block a user