GPU: cap cumulative wait per pipeline across frames and wake waiters on worker_lost (#217) #229
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!229
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@ESAT586 on GitHub · 2026-11-26 05:29 UTC · original
ESAT586:belobug/pipeline-wait-cap→main· +91 −7 · 1 files · 1 commits · openAddresses 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.)
@ySKELLETONX on GitHub · 2026-11-26 11:26 UTC · original
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.@gut0to on GitHub · 2026-11-26 15:52 UTC · original · reviewed
AI-assisted static review; I inspected the shared wait accounting and condition-variable path, but did not run tests or the game.
@ -169,0 +181,4 @@frame_slot: &AtomicU64,frame_waited_us: &AtomicU64,) -> bool {let pipeline_left = budget.saturating_sub(Duration::from_micros(p.waited_us.load(Ordering::Relaxed)));@gut0to on GitHub · 2026-11-26 15:52 UTC · original
Could 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.
@adrianmjim on GitHub · 2026-11-26 19:38 UTC · original
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.