timeline: wait for busy queues to finish before pump/submit returns (#116) #132
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!132
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-132"
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?
@adritoyalser on GitHub · 2026-11-25 15:31 UTC · original
adritoyalser:fix/timeline-submit-wait-busy→main· +130 −17 · 1 files · 1 commits · openSummary
Fixes #116 (implements Option 1 cleanly with a
Condvar+ RAII guard).Root Cause
Timeline::submit(andfence::signal) calltimeline::pump(), which steps every queue. When another thread (either thevictory-queueswatcher thread or another concurrent submitting thread) is already mid-step on a queue (s.busy == true),Timeline::stepreturnedfalseimmediately, lettingsubmit()/pump()return while ready work on that queue — or cross-queue work just unblocked by aSignal— was still running on the other thread.Changes
crates/victory-gpu/src/timeline.rs:done: CondvartoTimelineand an RAIIBusyGuardthat tracks a thread-localSTEPPINGnesting depth, clearss.busy, and callsdone.notify_all()on drop (including unwinds).Timeline::stepto returnStep::{Idle, Moved, Busy}.pump()(pump_inner(true)) to step all non-busy queues first, and if no queue moved while one isBusy(andSTEPPING == 0), wait onqueue.wait_not_busy()before re-pumping until every ready op across all queues has finished.victory-queueswatcher non-blocking (pump_inner(false)).submit_waits_for_busy_queue_on_another_threadandreentrant_submit_inside_work_does_not_deadlock.Verification
01aadd1): running thevictory-gputest binary onquery:: queue::failed 24 / 30 runs (page_mappings_run_after_a_queues_waitatqueue.rs:935,present_runs_after_a_queues_waitatqueue.rs:834).timeline::tests: 4 passed, 0 failed.query:: queue::stress test: 0 failures in 50 / 50 runs.cargo clippy -q -p victory-gpu --lib --tests --locked --no-deps: 0 warnings intimeline.rs.`Timeline::submit` and `fence::signal` rely on `timeline::pump` running all unblocked queue work before returning, but `Timeline::step` returned immediately when another thread (the `victory-queues` watcher or another submitting thread) held `busy == true` on a queue. As a result, a submit or signal could return while its own work (or cross-queue work it just unblocked) was still mid-flight on another thread. - Add a `Condvar` (`done`) on `Timeline` and an RAII `BusyGuard` that always clears `busy`, notifies waiters, and maintains a thread-local `STEPPING` nesting depth (even on unwind). - Have `Timeline::step` return `Step::{Idle, Moved, Busy}` so `pump` continues stepping any non-busy queues first, then waits on the first busy queue via `wait_not_busy()` and re-checks until all ready work has completed. - Skip waiting when called re-entrantly from inside `Timeline::step` (`STEPPING > 0`, preventing self-deadlock) or from the background `victory-queues` watcher (`pump_inner(false)`). - Add unit tests for concurrent submit-while-busy and re-entrant submit.@Adika713 on GitHub · 2026-11-25 15:49 UTC · original
Verified on AMD Radeon RX 6950 XT, Ryzen 5 3600, 32 GB RAM, Windows 11,
Rust 1.98.1 / Cargo 1.98.1. No game data; the title was not run.
I used the focused filters from #116 because full-lib serial runs on this
machine mostly hit the separate #102 watch flake
(
watch::tests::written_pages_are_reported_to_every_asker: 15/20 runs).Each tree used an isolated
CARGO_TARGET_DIR.Before, at
upstream/main01aadd193d57e71fb4d57810eb2fdd1bc95c950b, fromF:\VIctory-Belobug-AMDwithCARGO_TARGET_DIR=F:\VIctory-Belobug-AMD\_agent_tmp\target-gpu-main-verify:50 runs: 26 runs exited nonzero, including 2 hard exits with code
-1073740791and no test-result line. The 24 runs that reported a resultgave these failing test counts:
queue::tests::page_mappings_run_after_a_queues_wait: 10queue::tests::present_runs_after_a_queues_wait: 10queue::tests::queue_signals_complete_at_once: 7queue::tests::work_after_a_wait_runs_once_the_other_queue_signals: 5I did not see the query-named failures from #116 in this 50-run sample.
After, at PR head
62aad1f, from a detached worktree atF:\VIctory-Belobug-AMD\_agent_tmp\pr-132withCARGO_TARGET_DIR=F:\VIctory-Belobug-AMD\_agent_tmp\target-pr132-verify:test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 105 filtered out.timeline:::test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 113 filtered out.Overlap: PR #109 head
6febfefalso touchestimeline.rs, but with the samefocused command it still failed 19/30 runs (1 hard exit), with the same four
queue tests. I wrote no competing fix.
Not tested: the game, or the full workspace suite after this PR.
AI-assisted: OpenCode, model Big Pickle. No game data.
@adrianmjim on GitHub · 2026-11-25 18:57 UTC · original
RDNA3 data to go with the RX 6950 XT numbers above. RX 7900 XT, driver 32.0.32029.2010, Windows 11 build 26300, Rust 1.98.1. No game data, title not run. The lib test binary was run directly, interleaved with main
01aadd1under the same load (another GPU job was running).victory_gpu-*.exe queue:: query::, default threads, 60 runs each:queue_signals_complete_at_once21,page_mappings_run_after_a_queues_wait16,present_runs_after_a_queues_wait13,work_after_a_wait_runs_once_the_other_queue_signals8,occlusion_queries_around_draws_not_run_stay_visible2. Two of the main runs ended with no test-result line right after the occlusion query failure.62aad1f): 0/60.timeline::tests passed in every full-lib run on this tree (55) and on the combined tree (55).No new failures. The other failures on this tree also happen on main: #102 (this PR does not touch it),
frame::tests::waits_end_on_ticks_and_count_frames, and three guarded-viewwatch::tests. A few full-lib runs ended without a result line. They happened on trees without this PR too, so I can't tie them to it.Not tested: the title.
@battledogegames-design on GitHub · 2026-11-25 21:35 UTC · original
Deterministic regression test for busy-queue submit completion
Thanks for the queue-completion fix. I tested a small change to its regression coverage. If the second submitter is descheduled throughout the current 30 ms sleep, the first callback can finish before the second submission begins. Both assertions can then pass on an uncontended queue.
The replacement holds the first callback on a channel and observes the second submitter encountering that same queue busy. All 20 controlled runs recorded both completion bits in one load immediately after
submitreturned, joined the worker, and checked the saved snapshot. Cleanup cannot change that snapshot.01aadd162aad1fOn the PR, a test-only hook releases the worker when the submitter commits to waiting under the queue mutex. A different waiting mechanism would need an equivalent observation point. Production queue behavior is unchanged. Validation covered these synthetic tests only. The full workspace suite, independent-queue latency, physical-GPU behavior, and game execution remain untested here.
The ZIP includes
pr.patch, the baseline comparison, reproduction commands, and all 21 logs. Would you prefer to integrate the test into this PR or receive a separate test-only PR?issue-116-maintainer-review.zip
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.