refactor(mt): move job preparation order to Rust
Make Rust the owner of the compression-job preparation sequence: publish the descriptor, reset the reusable input state, and publish terminal frame state last. Keep all MT job and stream layouts in C behind three focused callbacks, and preserve the nonterminal and terminal branches exactly. Test Plan: ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings; cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check; GCC and Clang syntax-only checks; make -j1 -C tests test (all 41 shell tests, fuzzer, zstd tester, and zstream tester passed).
This commit is contained in:
@@ -547,6 +547,12 @@ typedef void (*ZSTDMT_prepareJobFn)(void* opaque, unsigned jobID,
|
||||
const ZSTDMT_RustJobInitialization* init);
|
||||
typedef void (*ZSTDMT_writeEmptyJobFn)(void* opaque, unsigned jobID);
|
||||
typedef int (*ZSTDMT_tryAddJobFn)(void* opaque, unsigned jobID);
|
||||
void ZSTDMT_rust_prepareCompressionJob(
|
||||
void* opaque, unsigned jobID,
|
||||
const ZSTDMT_RustJobInitialization* initialization,
|
||||
ZSTDMT_prepareJobFn initializeJob,
|
||||
ZSTDMT_prepareJobFn resetInputState,
|
||||
ZSTDMT_prepareJobFn publishFrameState);
|
||||
ZSTDMT_RustCreateJobResult ZSTDMT_rust_createCompressionJob(
|
||||
const ZSTDMT_RustCreateJobProjection* projection,
|
||||
void* opaque, ZSTDMT_prepareJobFn prepareJob,
|
||||
@@ -2877,7 +2883,7 @@ static void ZSTDMT_writeLastEmptyBlock(ZSTDMT_jobDescription* job)
|
||||
assert(!ZSTD_isError(job->cSize));
|
||||
}
|
||||
|
||||
static void ZSTDMT_prepareCompressionJob(
|
||||
static void ZSTDMT_prepareCompressionJobDescriptor(
|
||||
void* opaque, unsigned jobID,
|
||||
const ZSTDMT_RustJobInitialization* initialization)
|
||||
{
|
||||
@@ -2908,7 +2914,14 @@ static void ZSTDMT_prepareCompressionJob(
|
||||
job->lastJob = initialization->lastJob;
|
||||
job->frameChecksumNeeded = initialization->frameChecksumNeeded;
|
||||
job->dstFlushed = 0;
|
||||
}
|
||||
|
||||
static void ZSTDMT_prepareCompressionJobInputState(
|
||||
void* opaque, unsigned jobID,
|
||||
const ZSTDMT_RustJobInitialization* initialization)
|
||||
{
|
||||
ZSTDMT_CCtx* const mtctx = (ZSTDMT_CCtx*)opaque;
|
||||
(void)jobID;
|
||||
/* Update the round buffer position and clear the input buffer to be reset. */
|
||||
mtctx->roundBuff.pos += initialization->roundBuffPosDelta;
|
||||
mtctx->inBuff.buffer = g_nullBuffer;
|
||||
@@ -2917,6 +2930,14 @@ static void ZSTDMT_prepareCompressionJob(
|
||||
(const BYTE*)initialization->nextPrefixStart,
|
||||
initialization->nextPrefixSize
|
||||
};
|
||||
}
|
||||
|
||||
static void ZSTDMT_prepareCompressionJobFrameState(
|
||||
void* opaque, unsigned jobID,
|
||||
const ZSTDMT_RustJobInitialization* initialization)
|
||||
{
|
||||
ZSTDMT_CCtx* const mtctx = (ZSTDMT_CCtx*)opaque;
|
||||
(void)jobID;
|
||||
if (initialization->lastJob) {
|
||||
mtctx->frameEnded = 1;
|
||||
if (initialization->clearChecksumFlag)
|
||||
@@ -2924,6 +2945,17 @@ static void ZSTDMT_prepareCompressionJob(
|
||||
}
|
||||
}
|
||||
|
||||
static void ZSTDMT_prepareCompressionJob(
|
||||
void* opaque, unsigned jobID,
|
||||
const ZSTDMT_RustJobInitialization* initialization)
|
||||
{
|
||||
ZSTDMT_rust_prepareCompressionJob(
|
||||
opaque, jobID, initialization,
|
||||
ZSTDMT_prepareCompressionJobDescriptor,
|
||||
ZSTDMT_prepareCompressionJobInputState,
|
||||
ZSTDMT_prepareCompressionJobFrameState);
|
||||
}
|
||||
|
||||
static void ZSTDMT_writeEmptyCompressionJob(void* opaque, unsigned jobID)
|
||||
{
|
||||
ZSTDMT_CCtx* const mtctx = (ZSTDMT_CCtx*)opaque;
|
||||
|
||||
Reference in New Issue
Block a user