GPU: cap cumulative wait per pipeline across frames and wake waiters on worker_lost (#217) #229
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/229"
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 Belobug/VIctory-Belobug-AMD. Originally posted by ESAT586 on 2026-11-26T05:29:49Z.
Addresses the per-pipeline wait-budget half of #217 (complements #219 cleanly with no overlap in Pending::make).
Problem
Fix (crates/victory-gpu/src/pipeline/make.rs)
Verification (zero game data)
(Authored and verified with Gemini 4 Neon — High Mode, AI coding agent — with zero game data.)
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by ySKELLETONX on 2026-11-26T11:26:11Z.
Tested on RX 7600 XT (RDNA3), Windows 11, on top of
main4f62c2a, merged together with #219 (they merge cleanly):cargo test -p victory-gpu --lib --locked: 116 passed (113 onmain+ the 3 new tests from #219 and #229), 0 failed;pipeline::make::tests5/5 runs greencargo clippy -p victory-gpu --lib --tests: nothing inmake.rsRead through it:
lostis stored underAT_WORKbeforeworker_losttakesDONEto notify, so a waiter can't miss the wake-up. Two small notes:lost_worker_wakes_waiter_immediatelysetslostand notifies by hand, so it would still pass if the newnotify_allinworker_lostwere removed. It may be worth driving it throughworker_lost(or saying in the test that it covers the wait loop only).waited_us, so it can be cut off before a full budget of wall time has passed. Probably fine, but worth a line in the doc comment.This conflicts with #56: the
left.is_zero()early return there is already covered here (frame_left.min(pipeline_left)), while #56'sload-before-swaphunks inready/startdon't overlap.Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-26T15:52:05Z.
Review: COMMENTED
AI-assisted static review; I inspected the shared wait accounting and condition-variable path, but did not run tests or the game.
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by gut0to on 2026-11-26T15:52:06Z.
Code review location:
crates/victory-gpu/src/pipeline/make.rs; line 184Could this reserve the remaining allowance atomically before entering the condition-variable wait? Pending is shared by concurrent title threads, but each waiter reads waited_us here and charges it only after waking. Two callers can therefore both observe the full pipeline allowance, wait for that full interval concurrently, then add both intervals; the aggregate can exceed the per-pipeline cap. The same read-then-charge race applies to the shared frame allowance. A reservation/CAS or one waiter per Pending would enforce the stated aggregate budget.
Imported from Belobug/VIctory-Belobug-AMD. Originally posted by adrianmjim on 2026-11-26T19:38:36Z.
Checked on head
f8a76b1against main4f62c2a: Windows 11, RX 7900 XT, debug test builds only, no game. Other heavy jobs were running on the machine at the same time.The per-pipeline cap works here:
pipeline_wait_caps_total_wait_per_pipeline_across_framesthen fails, as it should.Panic in
make(), which the description leaves to #219:HostPipeline::newpanic in a worker (a test-only hook). After 10 s the pipeline was still being made,lostwas false andwaiting()was 1. It cost one budget (about 0.5 s) in all, not one per frame.maketests pass in 3 of 3 runs. That is the existing test, both PRs' tests and three of mine. One of mine sends a panic through a real worker.Tests in this PR:
lost_worker_wakes_waiter_immediatelyis racy. Iflostis set before the waiter thread reacheswait_with,wait_withreturnsfalseand theassert!on its return value fails.victory-gpu --libruns, interleaved with main, it failed 6 times. In a later set it failed 6 of 10. Every failure was on that assert. Run on its own, it failed once in 300 runs.AT_WORK, blocks a waiter inwait, then callsworker_lost(id). With the change, the waiter woke within 0.13 ms. Without thenotify_allinworker_lost, it woke after 513 ms.Other results:
watch::andqueue::tests, on both sides. Those are flaky on this machine under load.Not tested:
--features diagnostics.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.