Forget up-copy check entries for copies that are gone #412
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-logs
old-names
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!412
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-412"
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?
@safesearch77 on GitHub · 2026-11-28 13:26 UTC · original
safesearch77:fix/upcheck-forget-gone→main· +60106 −5430 · 206 files · 661 commits · closed without mergingWith
VICTORY_UPCOPY_CHECK=1,KNOWNinhost/upcheck.rskept an entry for every copy that was ever declared or fetched. It's never pruned, so it grows for the whole session. The look at rest now keeps only the ids still inshadow::carded_copies(), before anything in the look can fail.Why that's safe:
shadow.rsNEXT) and are never reused.CARDEDonly drops dead copies (card_dirty'sretainkeeps every liveWeak). A live copy is never forgotten while it is temporarily without a card piece.KNOWN's own lock (carded_known), so nothing can be declared or fetched between naming them and pruning. (The first version said the submission lock covered this; it doesn't, becausedeclared/fetchedalso run on the thread that lands flights. Fixed in the follow-up commitc15da1e.)This is a diagnostics-only path, off by default, so it doesn't change the default behaviour.
Ported from
trustno1-coder/VIctory-NVIDIA@8e9f11d(DiosET3RN0).Verification (Linux,
GE-Proton11-14Wine runner,x86_64-pc-windows-msvc)crate::host::host()isNone(no D3D12 host in that harness). This PR's new test is a pure CPU test, so it runs and passes.host::upcheck::tests::what_is_known_of_a_copy_that_is_gone_is_let_go: fails withoutforget_goneand passes with the fix.cargo +1.98.1 test -p victory-gpu --lib(Wine):523 passed; 5 failed(default) and589 passed; 6 failed(--features diagnostics), matching untouchedmain(fe7c6e5); zero new failures.cargo +1.98.1 clippy -p victory-gpu --all-targets -- -D warnings: clean, both default and--features diagnostics.cargo +1.98.1 xtask policy:asset policy: 322 files ok.@TaynanGT on GitHub · 2026-11-29 11:35 UTC · original
Thanks for addressing the growing diagnostic map. Please check that pruning cannot discard a live copy's entry while it is being inspected, and that a retired or reused identifier doesn't inherit stale state.
@safesearch77 on GitHub · 2026-11-29 13:20 UTC · original
Thanks, both points checked. The first one turned up a gap, now closed.
Can pruning drop a live copy's entry while it is being inspected? Not the way it's used, but the PR's stated reason was wrong. Here's the reasoning:
KNOWNis read in two places.look()reads entries of the copies it just named (carded_copies()), and the prune keeps exactly those.Looks::read()(the check at each send) reads the copiescard_dirty()handed torecord(). Those were carded when recorded, andLooksholds anArcto each.CARDEDonly drops aWeakthat no longer upgrades (or the test tracker drops it), so a copy that's still held stays incarded_copies(), and its entry survives.Shadowgets or loses its card side only when it's built, so a copy never becomes carded later under the same id.declared()andfetched()are called fromrelay_card_back, which runs on the thread that lands flights and is documented to take no submission lock. In practiceat_restonly runs whenflying()is false, and with the relay that includes flights still being landed. So I found no interleaving that hits it today. But the old code named the copies before takingKNOWN's lock, so a copy carded and declared in between would have been pruned while alive.KNOWN's lock is held (carded_known), sodeclared()andfetched()wait until the prune is done. That makes the guarantee local instead of depending on whenat_restruns. The lock order isKNOWN→CARDED. Nothing holdsCARDEDwhile asking forKNOWN:card_dirty,carded_copies, the counters and the push sites never call intoupcheck, andShadow::dropdoesn't touch it.Can a retired or reused id inherit stale state? No. Every
Shadowgets its number from one process-wideAtomicU64counter inShadow::new, starting at 1 and incremented once per copy.Shadow::placedgoes throughnewtoo. A number is never given twice. A new copy of the same title memory therefore starts with noKNOWNentry, so it doesn't inherit what was declared or fetched for the copy before it.KNOWNandNOTEDare keyed only by that number.Tests (CPU-only, using
Shadow::unbacked):copies_are_named_while_nothing_can_be_declared: the copies are named while the map's lock is held, and only the live copy's entry survives. It failed on the previous ordering ("the copies were named outside the lock") and passes now.a_copy_made_again_knows_nothing_of_the_one_before: two copies of the same span get increasing ids. After the first is declared, the second still reads "no shader was declared to write the buffer".Severity: this is diagnostics-only (
VICTORY_UPCOPY_CHECK=1). The worst case before was a misleading "never declared" line in the log, not a rendering problem.Verified under Wine:
victory-gpu --libpasses 525 with 5 failures by default, and 591 with 6 failures with--features diagnostics. Those are the same failures that predate this PR onmain(ambient::…indirect_hold…,host::readback_pool_tests::…,watch::…×3, plustimeline::report::…with diagnostics). Under Winehost()isNone, so only CPU-side results count.cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without--features diagnostics, andcargo xtask policy(322 files ok) are clean.AI-assisted: yes (Claude), reviewed locally before posting.
@TaynanGT on GitHub · 2026-11-29 14:39 UTC · original
Thanks for finding the gap in the original lock ordering. Naming the live copies under KNOWN and documenting the KNOWN-to-CARDED order is a stronger guarantee than relying on at_rest. The two focused tests are useful. I will retain the diagnostics-only scope and verify the restored implementation against the current tree.
@TaynanGT on GitHub · 2026-11-30 17:08 UTC · original
mainhas moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the currentmainand open a new PR; I'll review it there.Pull request closed