compilemem: isolate transient compile spikes & guard deferred compiles from refused/retry #2578
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2578"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by steven-seagull27 on 2026-11-29T14:34:25Z.
Summary
Fixes two tightly-coupled bugs in the shader-compile memory guard and pipeline failure reporting paths:
1. Prevent concurrent persistent allocations from poisoning
compilemem::Estimator(crates/victory-gpu/src/compilemem.rs)State::finishcomputedpeak.saturating_sub(r.private_at_start) / r.overlap.max(1)from whole-processPrivateUsage. When a shader compile overlapped a persistent allocation burst (such as buffers or textures committed while loading a scene), the compile was billed for gigabytes of unrelated persistent memory, inflatingEstimator::expected()for the rest of the session, throttling concurrent compilation, and trippingCOMMIT_FLOOR_MBprematurely.Create*PipelineStatereturns whereas persistent allocations stay committed atprivate_now,State::finishnow measures the transient compile spike abovebaseline = r.private_at_start.max(private_now):peak - max(start, now)).private_at_startare not overcounted as compile scratch.max(start, now)continue to be measured and shared across overlapping compiles.K32GetProcessMemoryInfo/figures_nowpolling insampler()andline()when no compiles are running.2. Do not falsely record memory-guard deferrals as permanent
0x8007000Efailures or bypasscompilememon retry (crates/victory-gpu/src/pipeline/host.rs,crates/victory-gpu/src/pipeline/refused.rs)compilemem::begindefers a compile,library::pipelinereturnsErr(memguard::refusal())(E_OUTOFMEMORY) with thread-localmemguard::deferred() == truesopipeline::makeretries it afterRETRY_AFTER_MS. However,HostPipeline::newcalledrefused::failed(...)andrefused::retry(...)unconditionally on error (compute, mesh, graphics, root signature):host pipeline failed (0x8007000e)inpipeline::refused.VICTORY_SHADER_CAPS=1was enabled,refused::retrycalledCreateComputePipelineState/CreateGraphicsPipelineStatedirectly on the driver, bypassingcompilememandmemguard.HostPipeline::newpipeline error handling throughon_pipeline_error, which returnsNoneimmediately whencrate::memguard::deferred()is true without recording a refusal or callingrefused::retry, while leaving the thread-local flag intact forpipeline::make'smemguard::take_deferred().crate::memguard::deferred()guards topipeline::refused::failedandpipeline::refused::retryas well.Testing
All tests are synthetic unit tests run in isolation (
--test-threads=1):cargo test --locked -j 2 -p victory-gpu --lib -- compilemem --nocapture --test-threads=1— 13 passed, 0 failed (including new tests for concurrent persistent growth, transient spike on top of persistent growth, fast unsampled compiles, unrelated frees below start, and overlapping compiles with persistent growth).cargo test --locked -j 2 -p victory-gpu --lib -- memguard --nocapture --test-threads=1— 6 passed, 0 failed.cargo test --locked -j 2 -p victory-gpu --lib -- pipeline:: --test-threads=1— 73 passed, 0 failed, 2 ignored (including new tests inpipeline::hostandpipeline::refusedverifying that deferred errors are not recorded inrefused, never invoke the retry closure, and preservememguard::deferred()fortake_deferred()).cargo clippy --locked -j 2 -p victory-gpu --lib --tests— passed with 0 warnings in touched files.git diff --check— clean.