feat(mt): move serial failure turn policy into Rust
Move the scalar failed-job skip decision and wrapping next-job transition into Rust. C keeps the serial mutex, error assertion, condition broadcast, and LDM window cleanup around the projected result. 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 -B -C programs -j1 zstd - ulimit -v 41943040; make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
This commit is contained in:
@@ -368,6 +368,12 @@ void ZSTDMT_rust_serialStateGenSequences(
|
||||
ZSTDMT_serialGenerateLdmFn generateLdm,
|
||||
ZSTDMT_serialUpdateChecksumFn updateChecksum,
|
||||
ZSTDMT_serialAdvanceFn advance);
|
||||
typedef struct {
|
||||
unsigned skip;
|
||||
unsigned nextJobID;
|
||||
} ZSTDMT_RustSerialEnsureFinishedResult;
|
||||
ZSTDMT_RustSerialEnsureFinishedResult ZSTDMT_rust_serialStateEnsureFinished(
|
||||
unsigned nextJobID, unsigned jobID);
|
||||
typedef void (*ZSTDMT_waitForLdmLockFn)(void* opaque);
|
||||
typedef int (*ZSTDMT_waitForLdmOverlapFn)(
|
||||
void* opaque, void* bufferStart, size_t bufferCapacity);
|
||||
@@ -975,11 +981,14 @@ ZSTDMT_serialState_applySequences(const SerialState* serialState, /* just for an
|
||||
static void ZSTDMT_serialState_ensureFinished(SerialState* serialState,
|
||||
unsigned jobID, size_t cSize)
|
||||
{
|
||||
ZSTDMT_RustSerialEnsureFinishedResult result;
|
||||
ZSTD_PTHREAD_MUTEX_LOCK(&serialState->mutex);
|
||||
if (serialState->nextJobID <= jobID) {
|
||||
result = ZSTDMT_rust_serialStateEnsureFinished(
|
||||
serialState->nextJobID, jobID);
|
||||
if (result.skip) {
|
||||
assert(ZSTD_isError(cSize)); (void)cSize;
|
||||
DEBUGLOG(5, "Skipping past job %u because of error", jobID);
|
||||
serialState->nextJobID = jobID + 1;
|
||||
serialState->nextJobID = result.nextJobID;
|
||||
ZSTD_pthread_cond_broadcast(&serialState->cond);
|
||||
|
||||
ZSTD_PTHREAD_MUTEX_LOCK(&serialState->ldmWindowMutex);
|
||||
|
||||
Reference in New Issue
Block a user