feat(compress): move CCtx block-state copy into Rust
Pass the destination compressed-block-state pointer slot and source state through the copyCCtx bridge, then perform the final copy in Rust after reset has established the destination. Remove the redundant C memcpy callback while preserving private callback ordering and early-error behavior. Add focused tests for copied repcodes and entropy repeat state. 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:
@@ -481,7 +481,8 @@ typedef struct {
|
||||
ZSTD_rust_copyCCtxMarkTables_f markTablesClean;
|
||||
ZSTD_rust_copyCCtxCopyState_f copyMatchState;
|
||||
ZSTD_rust_copyCCtxCopyState_f copyDictState;
|
||||
ZSTD_rust_copyCCtxCopyState_f copyBlockState;
|
||||
ZSTD_compressedBlockState_t** destinationBlockState;
|
||||
const ZSTD_compressedBlockState_t* sourceBlockState;
|
||||
int zbuff;
|
||||
} ZSTD_rust_copyCCtxInternalState;
|
||||
size_t ZSTD_rust_copyCCtxInternal(
|
||||
@@ -522,7 +523,7 @@ typedef char ZSTD_rust_copy_cctx_internal_state_layout[
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
&& offsetof(ZSTD_rust_copyCCtxInternalState, zbuff)
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
+ 9 * sizeof(void*)
|
||||
+ 10 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_copyCCtxInternalState)
|
||||
== ((offsetof(ZSTD_rust_copyCCtxInternalState, zbuff)
|
||||
+ sizeof(int) + sizeof(void*) - 1) / sizeof(void*))
|
||||
@@ -4854,16 +4855,6 @@ static void ZSTD_rust_copyCCtx_copy_dict_state(
|
||||
dst->dictContentSize = src->dictContentSize;
|
||||
}
|
||||
|
||||
static void ZSTD_rust_copyCCtx_copy_block_state(
|
||||
void* context, const void* srcCCtx)
|
||||
{
|
||||
ZSTD_CCtx* const dst = (ZSTD_CCtx*)context;
|
||||
const ZSTD_CCtx* const src = (const ZSTD_CCtx*)srcCCtx;
|
||||
ZSTD_memcpy(dst->blockState.prevCBlock,
|
||||
src->blockState.prevCBlock,
|
||||
sizeof(*src->blockState.prevCBlock));
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_copyCCtx_internal_callback(
|
||||
void* context, const void* srcCCtx,
|
||||
const ZSTD_frameParameters* fParams,
|
||||
@@ -4882,7 +4873,8 @@ static size_t ZSTD_rust_copyCCtx_internal_callback(
|
||||
state.markTablesClean = ZSTD_rust_copyCCtx_mark_tables_clean;
|
||||
state.copyMatchState = ZSTD_rust_copyCCtx_copy_match_state;
|
||||
state.copyDictState = ZSTD_rust_copyCCtx_copy_dict_state;
|
||||
state.copyBlockState = ZSTD_rust_copyCCtx_copy_block_state;
|
||||
state.destinationBlockState = &((ZSTD_CCtx*)context)->blockState.prevCBlock;
|
||||
state.sourceBlockState = ((const ZSTD_CCtx*)srcCCtx)->blockState.prevCBlock;
|
||||
state.zbuff = zbuff;
|
||||
return ZSTD_rust_copyCCtxInternal(&state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user