feat(cli): move adaptive refresh timing to Rust
The adaptive compression loop still delegated its refresh clock gate to a small C callback even though Rust already owned the iteration state and all adaptive policy decisions. That left timing policy, the last-refresh scalar, and one projection callback in the C-side orchestration boundary. Move the one-sixth-second monotonic refresh gate into ZstdAdaptiveState. The Rust loop now initializes the first refresh timestamp at frame start and preserves the C callback's strict-greater-than interval check. C retains only the private progression, parameter-setting, and diagnostic callbacks needed by the existing file I/O context. Shrink both sides of the projection together and keep compile-time offset and size assertions aligned. The adaptive unit fixture now verifies Rust records the refresh event while continuing to exercise the existing progression and policy callbacks. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo check --manifest-path rust/Cargo.toml --tests - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040; CARGO_BUILD_JOBS=1 make -j1 - ulimit -v 41943040; CARGO_BUILD_JOBS=1 make -j1 -C tests invalidDictionaries - ulimit -v 41943040; make -j1 -C tests test - git diff --check
This commit is contained in:
+6
-19
@@ -1643,7 +1643,6 @@ typedef char FIO_rust_zstd_progression_layout[
|
||||
== 4 * sizeof(U64) + sizeof(unsigned)
|
||||
&& sizeof(FIO_rust_zstd_progression_t)
|
||||
== 4 * sizeof(U64) + 2 * sizeof(unsigned)) ? 1 : -1];
|
||||
typedef int (*FIO_rust_zstd_adaptive_refresh_fn)(void* opaque);
|
||||
typedef void (*FIO_rust_zstd_adaptive_progression_fn)(
|
||||
void* opaque, FIO_rust_zstd_progression_t* progression);
|
||||
typedef void (*FIO_rust_zstd_adaptive_set_parameter_fn)(
|
||||
@@ -1672,7 +1671,6 @@ typedef struct {
|
||||
int minAdaptLevel;
|
||||
int maxAdaptLevel;
|
||||
int maxCLevel;
|
||||
FIO_rust_zstd_adaptive_refresh_fn adaptiveRefresh;
|
||||
FIO_rust_zstd_adaptive_progression_fn adaptiveProgression;
|
||||
FIO_rust_zstd_adaptive_set_parameter_fn adaptiveSetParameter;
|
||||
FIO_rust_zstd_adaptive_diagnostic_fn adaptiveDiagnostic;
|
||||
@@ -1684,15 +1682,18 @@ typedef char FIO_rust_zstd_compress_projection_layout[
|
||||
== 14 * sizeof(void*) + sizeof(int)
|
||||
&& offsetof(FIO_rust_zstd_compress_projection_t, maxCLevel)
|
||||
== 14 * sizeof(void*) + 4 * sizeof(int)
|
||||
&& offsetof(FIO_rust_zstd_compress_projection_t, adaptiveRefresh)
|
||||
&& offsetof(FIO_rust_zstd_compress_projection_t, adaptiveProgression)
|
||||
== ((14 * sizeof(void*) + 5 * sizeof(int) + sizeof(void*) - 1)
|
||||
/ sizeof(void*)) * sizeof(void*)
|
||||
&& offsetof(FIO_rust_zstd_compress_projection_t, adaptiveSetParameter)
|
||||
== ((14 * sizeof(void*) + 5 * sizeof(int) + sizeof(void*) - 1)
|
||||
/ sizeof(void*)) * sizeof(void*) + sizeof(void*)
|
||||
&& offsetof(FIO_rust_zstd_compress_projection_t, adaptiveDiagnostic)
|
||||
== ((14 * sizeof(void*) + 5 * sizeof(int) + sizeof(void*) - 1)
|
||||
/ sizeof(void*)) * sizeof(void*) + 3 * sizeof(void*)
|
||||
/ sizeof(void*)) * sizeof(void*) + 2 * sizeof(void*)
|
||||
&& sizeof(FIO_rust_zstd_compress_projection_t)
|
||||
== ((14 * sizeof(void*) + 5 * sizeof(int) + sizeof(void*) - 1)
|
||||
/ sizeof(void*)) * sizeof(void*) + 4 * sizeof(void*))
|
||||
/ sizeof(void*)) * sizeof(void*) + 3 * sizeof(void*))
|
||||
? 1 : -1];
|
||||
|
||||
int FIO_rust_compressZstdFrame(
|
||||
@@ -2882,7 +2883,6 @@ enum {
|
||||
typedef struct {
|
||||
FIO_ctx_t* fCtx;
|
||||
ZSTD_CCtx* cctx;
|
||||
UTIL_time_t lastAdaptTime;
|
||||
U64 srcFileSize;
|
||||
UTIL_HumanReadableSize_t fileHrs;
|
||||
} FIO_rust_zstd_projection_context_t;
|
||||
@@ -2936,17 +2936,6 @@ static void FIO_rust_zstd_sparseWriteEnd(void* opaque)
|
||||
AIO_WritePool_sparseWriteEnd((WritePoolCtx_t*)opaque);
|
||||
}
|
||||
|
||||
static int FIO_rust_zstd_adaptiveRefresh(void* opaque)
|
||||
{
|
||||
FIO_rust_zstd_projection_context_t* const context =
|
||||
(FIO_rust_zstd_projection_context_t*)opaque;
|
||||
if (UTIL_clockSpanMicro(context->lastAdaptTime) > REFRESH_RATE) {
|
||||
context->lastAdaptTime = UTIL_getTime();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void FIO_rust_zstd_adaptiveProgression(
|
||||
void* opaque, FIO_rust_zstd_progression_t* projection)
|
||||
{
|
||||
@@ -3110,7 +3099,6 @@ FIO_rust_compressZstdCallback(void* fCtx, void* prefs, void* ress,
|
||||
memset(&context, 0, sizeof(context));
|
||||
context.fCtx = fCtxPtr;
|
||||
context.cctx = ressPtr->cctx;
|
||||
context.lastAdaptTime = UTIL_getTime();
|
||||
context.srcFileSize = srcFileSize;
|
||||
context.fileHrs = UTIL_makeHumanReadableSize(srcFileSize);
|
||||
|
||||
@@ -3134,7 +3122,6 @@ FIO_rust_compressZstdCallback(void* fCtx, void* prefs, void* ress,
|
||||
projection.minAdaptLevel = prefsPtr->minAdaptLevel;
|
||||
projection.maxAdaptLevel = prefsPtr->maxAdaptLevel;
|
||||
projection.maxCLevel = ZSTD_maxCLevel();
|
||||
projection.adaptiveRefresh = FIO_rust_zstd_adaptiveRefresh;
|
||||
projection.adaptiveProgression = FIO_rust_zstd_adaptiveProgression;
|
||||
projection.adaptiveSetParameter = FIO_rust_zstd_adaptiveSetParameter;
|
||||
projection.adaptiveDiagnostic = FIO_rust_zstd_adaptiveDiagnostic;
|
||||
|
||||
Reference in New Issue
Block a user