feat(compress): move frame chunk internal blocks into Rust
Route frame-chunk internal blocks through the projected build-sequence-store and block-internal state, using a Rust-owned frame-chunk leaf while retaining the target and split callbacks in C. Refresh the per-block isFirstBlock snapshot for the direct path so its behavior remains identical to the former C adapter, and remove the obsolete C frame-chunk and block-internal adapters. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo fmt --manifest-path rust/Cargo.toml --all -- --check - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --lib - 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
This commit is contained in:
@@ -815,6 +815,8 @@ typedef char ZSTD_rust_frame_chunk_prepare_state_layout[
|
||||
== 5 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_frameChunkPrepareState) == 6 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
typedef struct ZSTD_rust_compressContinueBlockState_s
|
||||
ZSTD_rust_compressContinueBlockState;
|
||||
typedef size_t (*ZSTD_rust_frameChunkCompress_f)(void* context,
|
||||
void* dst,
|
||||
size_t dstCapacity,
|
||||
@@ -840,6 +842,7 @@ typedef struct {
|
||||
ZSTD_rust_frameChunkCompress_f compressTarget;
|
||||
ZSTD_rust_frameChunkCompress_f compressSplit;
|
||||
ZSTD_rust_frameChunkCompress_f compressInternal;
|
||||
const ZSTD_rust_compressContinueBlockState* compressInternalState;
|
||||
} ZSTD_rust_frameChunkState;
|
||||
size_t ZSTD_rust_compressFrameChunk(
|
||||
const ZSTD_rust_frameChunkState* state,
|
||||
@@ -869,8 +872,10 @@ typedef char ZSTD_rust_frame_chunk_state_layout[
|
||||
== 7 * sizeof(void*) + sizeof(S64) + 5 * sizeof(int)
|
||||
&& offsetof(ZSTD_rust_frameChunkState, prepareState)
|
||||
== 7 * sizeof(void*) + sizeof(S64) + 6 * sizeof(int)
|
||||
&& offsetof(ZSTD_rust_frameChunkState, compressInternalState)
|
||||
== 11 * sizeof(void*) + sizeof(S64) + 6 * sizeof(int)
|
||||
&& sizeof(ZSTD_rust_frameChunkState)
|
||||
== 11 * sizeof(void*) + sizeof(S64) + 6 * sizeof(int))
|
||||
== 12 * sizeof(void*) + sizeof(S64) + 6 * sizeof(int))
|
||||
? 1 : -1];
|
||||
|
||||
/* The high-level continue/block entry points are Rust-owned. This projection
|
||||
@@ -5363,32 +5368,6 @@ ZSTD_compressBlock_splitBlock(ZSTD_CCtx* zc,
|
||||
return cSize;
|
||||
}
|
||||
|
||||
static size_t
|
||||
ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize, U32 frame)
|
||||
{
|
||||
ZSTD_rust_blockInternalState state;
|
||||
size_t const bss = ZSTD_buildSeqStore(zc, src, srcSize);
|
||||
DEBUGLOG(5, "ZSTD_compressBlock_internal (dstCapacity=%u, dictLimit=%u, nextToUpdate=%u)",
|
||||
(unsigned)dstCapacity, (unsigned)zc->blockState.matchState.window.dictLimit,
|
||||
(unsigned)zc->blockState.matchState.nextToUpdate);
|
||||
FORWARD_IF_ERROR(bss, "ZSTD_buildSeqStore failed");
|
||||
|
||||
state.seqStore = &zc->seqStore;
|
||||
state.prevCBlock = &zc->blockState.prevCBlock;
|
||||
state.nextCBlock = &zc->blockState.nextCBlock;
|
||||
state.tmpWorkspace = zc->tmpWorkspace;
|
||||
state.tmpWkspSize = zc->tmpWkspSize;
|
||||
state.seqCollector = &zc->seqCollector;
|
||||
state.strategy = (int)zc->appliedParams.cParams.strategy;
|
||||
state.disableLiteralCompression = ZSTD_literalsCompressionIsDisabled(&zc->appliedParams);
|
||||
state.bmi2 = zc->bmi2;
|
||||
state.isFirstBlock = zc->isFirstBlock;
|
||||
return ZSTD_rust_compressBlockInternalAfterBuild(
|
||||
&state, dst, dstCapacity, src, srcSize, frame, (int)bss);
|
||||
}
|
||||
|
||||
static size_t ZSTD_compressBlock_targetCBlockSize(ZSTD_CCtx* zc,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize,
|
||||
@@ -5425,10 +5404,10 @@ typedef struct {
|
||||
const ZSTD_CCtx_params* params;
|
||||
} ZSTD_rust_overflowCorrectContext;
|
||||
|
||||
typedef struct {
|
||||
struct ZSTD_rust_compressContinueBlockState_s {
|
||||
const ZSTD_rust_buildSeqStoreState* buildSeqStoreState;
|
||||
const ZSTD_rust_blockInternalState* blockInternalState;
|
||||
} ZSTD_rust_compressContinueBlockState;
|
||||
};
|
||||
typedef char ZSTD_rust_compress_continue_block_state_layout[
|
||||
(sizeof(ZSTD_rust_compressContinueBlockState) == 2 * sizeof(void*)) ? 1 : -1];
|
||||
|
||||
@@ -5576,16 +5555,6 @@ static size_t ZSTD_rust_frameChunk_compressSplit(
|
||||
(ZSTD_CCtx*)context, dst, dstCapacity, src, srcSize, lastBlock);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_frameChunk_compressInternal(
|
||||
void* context, void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize, U32 lastBlock)
|
||||
{
|
||||
(void)lastBlock;
|
||||
return ZSTD_compressBlock_internal(
|
||||
(ZSTD_CCtx*)context, dst, dstCapacity, src, srcSize,
|
||||
1 /* frame */);
|
||||
}
|
||||
|
||||
static void ZSTD_compressContinue_prepare(
|
||||
ZSTD_CCtx* cctx, size_t blockSizeMax, int checkBlockSize,
|
||||
ZSTD_rust_compressContinueContext* context)
|
||||
@@ -5634,7 +5603,7 @@ static void ZSTD_compressContinue_prepare(
|
||||
context->frameChunkState.prepareState = &context->frameChunkPrepareState;
|
||||
context->frameChunkState.compressTarget = ZSTD_rust_frameChunk_compressTarget;
|
||||
context->frameChunkState.compressSplit = ZSTD_rust_frameChunk_compressSplit;
|
||||
context->frameChunkState.compressInternal = ZSTD_rust_frameChunk_compressInternal;
|
||||
context->frameChunkState.compressInternal = NULL;
|
||||
|
||||
ZSTD_initBuildSeqStoreState(cctx, &context->buildSeqStoreState);
|
||||
context->blockInternalState.seqStore = &cctx->seqStore;
|
||||
@@ -5650,6 +5619,7 @@ static void ZSTD_compressContinue_prepare(
|
||||
context->blockInternalState.isFirstBlock = cctx->isFirstBlock;
|
||||
context->blockState.buildSeqStoreState = &context->buildSeqStoreState;
|
||||
context->blockState.blockInternalState = &context->blockInternalState;
|
||||
context->frameChunkState.compressInternalState = &context->blockState;
|
||||
|
||||
context->overflowContext.matchState = ms;
|
||||
context->overflowContext.workspace = &cctx->workspace;
|
||||
|
||||
Reference in New Issue
Block a user