refactor(mt): move per-job parameter policy to Rust
Move the pure multithreaded worker-parameter policy into Rust: only the first job keeps the frame checksum flag, worker jobs disable LDM, and every worker context runs with zero nested workers. Keep the complete C-owned parameter structure and codec initialization in the adapter, crossing the ABI with a small layout-checked scalar projection. Test Plan: - rustfmt --edition 2021 --check rust/src/zstdmt_compress.rs - 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; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --all-targets - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/cli/Cargo.toml --all-targets - ulimit -v 41943040; make -j1 -C tests test
This commit is contained in:
@@ -190,6 +190,22 @@ typedef ZSTDMT_chunkProcessResult (*ZSTDMT_compressionJobCompressFn)(
|
||||
typedef void (*ZSTDMT_compressionJobErrorFn)(void* opaque, size_t error);
|
||||
typedef void (*ZSTDMT_compressionJobFinishFn)(void* opaque, size_t lastBlockSize);
|
||||
|
||||
typedef struct {
|
||||
int checksumFlag;
|
||||
int ldmEnable;
|
||||
unsigned nbWorkers;
|
||||
} ZSTDMT_RustCompressionJobParameters;
|
||||
typedef char ZSTDMT_compression_job_parameters_layout[
|
||||
(offsetof(ZSTDMT_RustCompressionJobParameters, checksumFlag) == 0
|
||||
&& offsetof(ZSTDMT_RustCompressionJobParameters, ldmEnable) == sizeof(int)
|
||||
&& offsetof(ZSTDMT_RustCompressionJobParameters, nbWorkers) == 2 * sizeof(int)
|
||||
&& sizeof(ZSTDMT_RustCompressionJobParameters)
|
||||
== 2 * sizeof(int) + sizeof(unsigned))
|
||||
? 1 : -1];
|
||||
|
||||
ZSTDMT_RustCompressionJobParameters ZSTDMT_rust_prepareCompressionJobParameters(
|
||||
unsigned jobID, int checksumFlag, int ldmEnable, unsigned nbWorkers);
|
||||
|
||||
void ZSTDMT_rust_compressionJob(
|
||||
const ZSTDMT_RustCompressionJobProjection* projection,
|
||||
void* opaque,
|
||||
@@ -1471,14 +1487,16 @@ static void ZSTDMT_compressionJobPrepareParameters(void* opaque)
|
||||
ZSTDMT_compressionJobState* const state =
|
||||
(ZSTDMT_compressionJobState*)opaque;
|
||||
ZSTDMT_jobDescription* const job = state->job;
|
||||
ZSTDMT_RustCompressionJobParameters const parameters =
|
||||
ZSTDMT_rust_prepareCompressionJobParameters(
|
||||
job->jobID,
|
||||
state->jobParams.fParams.checksumFlag,
|
||||
state->jobParams.ldmParams.enableLdm,
|
||||
(unsigned)state->jobParams.nbWorkers);
|
||||
|
||||
/* Don't compute the checksum for chunks, since we compute it externally,
|
||||
* but write it in the header. */
|
||||
if (job->jobID != 0) state->jobParams.fParams.checksumFlag = 0;
|
||||
/* Don't run LDM for the chunks, since we handle it externally. */
|
||||
state->jobParams.ldmParams.enableLdm = ZSTD_ps_disable;
|
||||
/* Correct nbWorkers to 0. */
|
||||
state->jobParams.nbWorkers = 0;
|
||||
state->jobParams.fParams.checksumFlag = parameters.checksumFlag;
|
||||
state->jobParams.ldmParams.enableLdm = parameters.ldmEnable;
|
||||
state->jobParams.nbWorkers = (int)parameters.nbWorkers;
|
||||
}
|
||||
|
||||
static void ZSTDMT_compressionJobGenerateSequences(void* opaque)
|
||||
|
||||
Reference in New Issue
Block a user