feat(compress): move CDict metadata copies into Rust
Pass CCtx destination fields and CDict source fields through the attach and copy bridges, then copy dictID and dictContentSize in Rust at the original metadata-copy point. Remove the redundant C metadata callbacks while keeping reset error handling, attach ordering, and block-state copy ordering intact. Add focused tests for metadata values and callback sequencing. 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:
@@ -2497,7 +2497,10 @@ typedef struct {
|
||||
ZSTD_rust_resetCCtxByCopyingCDictState_f zeroHashTable3;
|
||||
ZSTD_rust_resetCCtxByCopyingCDictMarkTables_f markTablesClean;
|
||||
ZSTD_rust_resetCCtxByCopyingCDictState_f copyMatchState;
|
||||
ZSTD_rust_resetCCtxByCopyingCDictState_f copyDictState;
|
||||
U32* destinationDictID;
|
||||
const U32* sourceDictID;
|
||||
size_t* destinationDictContentSize;
|
||||
const size_t* sourceDictContentSize;
|
||||
ZSTD_compressedBlockState_t** destinationBlockState;
|
||||
const ZSTD_compressedBlockState_t* sourceBlockState;
|
||||
int zbuff;
|
||||
@@ -2515,7 +2518,7 @@ typedef char ZSTD_rust_reset_cctx_by_copying_cdict_state_layout[
|
||||
&& offsetof(ZSTD_rust_resetCCtxByCopyingCDictState, reset)
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
&& offsetof(ZSTD_rust_resetCCtxByCopyingCDictState, zbuff)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 9 * sizeof(void*)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 12 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_resetCCtxByCopyingCDictState)
|
||||
== ((offsetof(ZSTD_rust_resetCCtxByCopyingCDictState, zbuff)
|
||||
+ sizeof(int) + sizeof(void*) - 1) / sizeof(void*))
|
||||
@@ -2526,8 +2529,6 @@ typedef size_t (*ZSTD_rust_resetCCtxByAttachingCDictReset_f)(
|
||||
U64 pledgedSrcSize, int zbuff);
|
||||
typedef void (*ZSTD_rust_resetCCtxByAttachingCDictAttach_f)(
|
||||
void* context, const void* cdict);
|
||||
typedef void (*ZSTD_rust_resetCCtxByAttachingCDictState_f)(
|
||||
void* context, const void* cdict);
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
const void* cdict;
|
||||
@@ -2535,7 +2536,10 @@ typedef struct {
|
||||
U64 pledgedSrcSize;
|
||||
ZSTD_rust_resetCCtxByAttachingCDictReset_f reset;
|
||||
ZSTD_rust_resetCCtxByAttachingCDictAttach_f attach;
|
||||
ZSTD_rust_resetCCtxByAttachingCDictState_f copyDictState;
|
||||
U32* destinationDictID;
|
||||
const U32* sourceDictID;
|
||||
size_t* destinationDictContentSize;
|
||||
const size_t* sourceDictContentSize;
|
||||
ZSTD_compressedBlockState_t** destinationBlockState;
|
||||
const ZSTD_compressedBlockState_t* sourceBlockState;
|
||||
int zbuff;
|
||||
@@ -2553,7 +2557,7 @@ typedef char ZSTD_rust_reset_cctx_by_attaching_cdict_state_layout[
|
||||
&& offsetof(ZSTD_rust_resetCCtxByAttachingCDictState, reset)
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
&& offsetof(ZSTD_rust_resetCCtxByAttachingCDictState, zbuff)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 5 * sizeof(void*)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 8 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_resetCCtxByAttachingCDictState)
|
||||
== ((offsetof(ZSTD_rust_resetCCtxByAttachingCDictState, zbuff)
|
||||
+ sizeof(int) + sizeof(void*) - 1) / sizeof(void*))
|
||||
@@ -4512,15 +4516,6 @@ static void ZSTD_rust_resetCCtx_byAttachingCDict_attach(
|
||||
cctx->blockState.matchState.window.dictLimit;
|
||||
}
|
||||
|
||||
static void ZSTD_rust_resetCCtx_byAttachingCDict_copy_dict_state(
|
||||
void* context, const void* cdictOpaque)
|
||||
{
|
||||
ZSTD_CCtx* const cctx = (ZSTD_CCtx*)context;
|
||||
const ZSTD_CDict* const cdict = (const ZSTD_CDict*)cdictOpaque;
|
||||
cctx->dictID = cdict->dictID;
|
||||
cctx->dictContentSize = cdict->dictContentSize;
|
||||
}
|
||||
|
||||
static size_t
|
||||
ZSTD_resetCCtx_byAttachingCDict(ZSTD_CCtx* cctx,
|
||||
const ZSTD_CDict* cdict,
|
||||
@@ -4535,7 +4530,10 @@ ZSTD_resetCCtx_byAttachingCDict(ZSTD_CCtx* cctx,
|
||||
state.pledgedSrcSize = pledgedSrcSize;
|
||||
state.reset = ZSTD_rust_resetCCtx_byAttachingCDict_reset;
|
||||
state.attach = ZSTD_rust_resetCCtx_byAttachingCDict_attach;
|
||||
state.copyDictState = ZSTD_rust_resetCCtx_byAttachingCDict_copy_dict_state;
|
||||
state.destinationDictID = &cctx->dictID;
|
||||
state.sourceDictID = &cdict->dictID;
|
||||
state.destinationDictContentSize = &cctx->dictContentSize;
|
||||
state.sourceDictContentSize = &cdict->dictContentSize;
|
||||
state.destinationBlockState = &cctx->blockState.prevCBlock;
|
||||
state.sourceBlockState = &cdict->cBlockState;
|
||||
state.zbuff = (int)zbuff;
|
||||
@@ -4653,15 +4651,6 @@ static void ZSTD_rust_resetCCtx_byCopyingCDict_copy_match_state(
|
||||
dst->loadedDictEnd = src->loadedDictEnd;
|
||||
}
|
||||
|
||||
static void ZSTD_rust_resetCCtx_byCopyingCDict_copy_dict_state(
|
||||
void* context, const void* cdictOpaque)
|
||||
{
|
||||
ZSTD_CCtx* const cctx = (ZSTD_CCtx*)context;
|
||||
const ZSTD_CDict* const cdict = (const ZSTD_CDict*)cdictOpaque;
|
||||
cctx->dictID = cdict->dictID;
|
||||
cctx->dictContentSize = cdict->dictContentSize;
|
||||
}
|
||||
|
||||
static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx,
|
||||
const ZSTD_CDict* cdict,
|
||||
ZSTD_CCtx_params params,
|
||||
@@ -4683,8 +4672,10 @@ static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx,
|
||||
ZSTD_rust_resetCCtx_byCopyingCDict_mark_tables_clean;
|
||||
state.copyMatchState =
|
||||
ZSTD_rust_resetCCtx_byCopyingCDict_copy_match_state;
|
||||
state.copyDictState =
|
||||
ZSTD_rust_resetCCtx_byCopyingCDict_copy_dict_state;
|
||||
state.destinationDictID = &cctx->dictID;
|
||||
state.sourceDictID = &cdict->dictID;
|
||||
state.destinationDictContentSize = &cctx->dictContentSize;
|
||||
state.sourceDictContentSize = &cdict->dictContentSize;
|
||||
state.destinationBlockState = &cctx->blockState.prevCBlock;
|
||||
state.sourceBlockState = &cdict->cBlockState;
|
||||
state.zbuff = (int)zbuff;
|
||||
|
||||
Reference in New Issue
Block a user