Upload ahead: a list waits for an upload still being taken (copy-queue race) #536
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!536
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-536"
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?
@MamaLeVrai on GitHub · 2026-11-27 10:18 UTC · original
MamaLeVrai:upload-ahead-race→a-publier· +75 −1 · 1 files · 1 commits · openWhat
A race between the upload-ahead copy queue (
VICTORY_UPLOAD_AHEAD,texture/ahead.rs) and a list that uploads the same texture on the drawing queue.claim()marks a texture as on its way before its job exists. It then builds the staging buffer while holding the staging lock (texture.rs~1839), and only after that puts the job in the "on their way" list.listed(), which a list calls before it records an upload (texture.rs~751), waited only while the job was in that list, and gave up after 1 s.So a list that uploads the same texture inside that window, or more than 1 s later, recorded its copy on the drawing queue while the copy queue wrote the same texture. The copy-queue worker also rewrites the staging buffer the drawing-queue copy reads.
Fix (
ahead.rs):listed()now waits for the texture to leave the "on its way" state, not for its job in the list. The wait is capped at 10 s, with a log line if it runs out. Aclaim()that gives up after marking the texture wakes any list waiting on it.Test
texture::ahead::tests::a_list_waits_for_an_upload_still_being_takenholds the staging lock to freezeclaim()inside the window, then callslisted()from another thread.listed()returned while the upload was still on its way (left: Ok(1), right: Ok(2));a_placed_texture_is_filled_ahead_of_the_lists. Clippy on victory-gpu: 0 warnings.Not claimed
This is not relay-only (
ahead::takedepends onVICTORY_SHOW_AFTER), and RDNA 2 players withVICTORY_RELAY=0andVICTORY_UPLOAD_AHEAD=1don't crash. So it is unlikely to be the cause of the RDNA 2 resets (#376); with relay on, the overlap just gets more likely. Not run in the game.One theoretical case: a thread calling
listed()between its ownclaim()andsend()would stand for up to 10 s. No such path was found.AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 10:18 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@gw1337x on GitHub · 2026-11-27 11:13 UTC · original · edited 2026-11-27 11:52 UTC
In-game check on RDNA 3, with
VICTORY_UPLOAD_AHEAD=1on (part of the setting I test with). Memory Integrity was off.PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. Test: 270 s hands-off boat scene, RT off, warm caches. #536 on
4eb6cfdvs4eb6cfd, runs interleaved (PR, base, PR).4eb6cfdbuild, 10:52) shows the same dark deck over the same span, so it isn't specific to this PR.No measurable change and no regression in this scene. This doesn't test whether the race itself shows up here.
@MamaLeVrai on GitHub · 2026-11-27 11:32 UTC · original
Thanks @gw1337x. That fits what the PR should do: no fps change, list waits and longest uploads within the base range, and no device loss. The race only shows when a list uploads the same texture inside the claim window, which a hands-off boat scene may rarely hit. The unit test is the proof of the fix, and your runs are the check that it costs nothing here. The 34.8 GB peak commit in run 1 is worth watching if it repeats, but nothing in this change allocates more.
AI-assisted (Claude Code); no game data.
@gut0to on GitHub · 2026-11-27 13:28 UTC · original · reviewed
AI-assisted review: I traced the timeout path through
listed()and its caller, which continues recording the list upload after this function returns.@ -157,2 +168,3 @@let started = std::time::Instant::now();while way.iter().any(|(serial, _)| *serial == copy.serial) && started.elapsed().as_millis() < 1000 {while copy.ahead.load(Relaxed) == PENDING {if started.elapsed().as_secs() >= 10 {@gut0to on GitHub · 2026-11-27 13:28 UTC · original
After 10 seconds this returns while
copy.aheadis stillPENDING, so the caller proceeds with its drawing-queue upload even though the copy-queue job may still write the same texture and refresh the staging buffer. That is the original race with a longer timeout. Could the timeout cancel/retire the pending claim or otherwise prevent the duplicate upload before returning? If cancellation is not possible, the caller needs a safe failure path instead of continuing concurrently.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.