feat(mt): move worker trace policy to Rust
Move the first-job versus continuation-job trace policy out of the C worker callback. Rust now decides when the external-dictionary assertion is required and orders it before the trace, while C retains the private window assertion and trace-recording leaves. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo check --tests - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --tests -- -A clippy::manual-bits -D warnings - ulimit -v 41943040; make -j1 - ulimit -v 41943040; make -j1 -C tests test
This commit is contained in:
@@ -362,6 +362,24 @@ typedef char ZSTDMT_compression_job_finish_projection_layout[
|
||||
+ sizeof(ZSTDMT_RustCompressionJobFinishPublicationProjection))
|
||||
? 1 : -1];
|
||||
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
unsigned firstJob;
|
||||
ZSTDMT_compressionJobVoidFn assertNoExtDict;
|
||||
ZSTDMT_compressionJobVoidFn trace;
|
||||
} ZSTDMT_RustCompressionJobTraceProjection;
|
||||
typedef char ZSTDMT_compression_job_trace_projection_layout[
|
||||
(offsetof(ZSTDMT_RustCompressionJobTraceProjection, callbackContext) == 0
|
||||
&& offsetof(ZSTDMT_RustCompressionJobTraceProjection, firstJob)
|
||||
== sizeof(void*)
|
||||
&& offsetof(ZSTDMT_RustCompressionJobTraceProjection, assertNoExtDict)
|
||||
== 2 * sizeof(void*)
|
||||
&& offsetof(ZSTDMT_RustCompressionJobTraceProjection, trace)
|
||||
== 3 * sizeof(void*)
|
||||
&& sizeof(ZSTDMT_RustCompressionJobTraceProjection)
|
||||
== 4 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
|
||||
typedef struct {
|
||||
int checksumFlag;
|
||||
int ldmEnable;
|
||||
@@ -422,6 +440,8 @@ void ZSTDMT_rust_compressionJob(
|
||||
ZSTDMT_compressionJobApplySequencesFn applySequences,
|
||||
ZSTDMT_compressionJobCompressFn compressJob,
|
||||
ZSTDMT_compressionJobVoidFn traceJob);
|
||||
void ZSTDMT_rust_compressionJobTrace(
|
||||
const ZSTDMT_RustCompressionJobTraceProjection* projection);
|
||||
|
||||
ZSTDMT_chunkProcessResult ZSTDMT_rust_compressJobChunks(
|
||||
ZSTD_CCtx* cctx, const void* src, size_t srcSize,
|
||||
@@ -2247,18 +2267,34 @@ static ZSTDMT_chunkProcessResult ZSTDMT_compressionJobCompress(
|
||||
&progress, ZSTDMT_rust_compressionJobProgress);
|
||||
}
|
||||
|
||||
static void ZSTDMT_compressionJobTraceAssertNoExtDict(void* opaque)
|
||||
{
|
||||
ZSTDMT_compressionJobState* const state =
|
||||
(ZSTDMT_compressionJobState*)opaque;
|
||||
|
||||
/* Double check that we don't have an ext-dict, because then our repcode
|
||||
* invalidation doesn't work. */
|
||||
assert(!ZSTD_window_hasExtDict(state->cctx->blockState.matchState.window));
|
||||
}
|
||||
|
||||
static void ZSTDMT_compressionJobTraceRecord(void* opaque)
|
||||
{
|
||||
ZSTDMT_compressionJobState* const state =
|
||||
(ZSTDMT_compressionJobState*)opaque;
|
||||
ZSTD_CCtx_trace(state->cctx, 0);
|
||||
}
|
||||
|
||||
static void ZSTDMT_compressionJobTrace(void* opaque)
|
||||
{
|
||||
ZSTDMT_compressionJobState* const state =
|
||||
(ZSTDMT_compressionJobState*)opaque;
|
||||
ZSTDMT_jobDescription* const job = state->job;
|
||||
|
||||
if (!job->firstJob) {
|
||||
/* Double check that we don't have an ext-dict, because then our
|
||||
* repcode invalidation doesn't work. */
|
||||
assert(!ZSTD_window_hasExtDict(state->cctx->blockState.matchState.window));
|
||||
}
|
||||
ZSTD_CCtx_trace(state->cctx, 0);
|
||||
ZSTDMT_RustCompressionJobTraceProjection const projection = {
|
||||
state,
|
||||
state->job->firstJob,
|
||||
ZSTDMT_compressionJobTraceAssertNoExtDict,
|
||||
ZSTDMT_compressionJobTraceRecord
|
||||
};
|
||||
ZSTDMT_rust_compressionJobTrace(&projection);
|
||||
}
|
||||
|
||||
static void ZSTDMT_compressionJobEnsureFinished(void* opaque)
|
||||
|
||||
Reference in New Issue
Block a user