Textures: slot eviction lets the table go before it touches a slot (lock ring, watchdog) #1969

Closed
github-bot wants to merge 1 commit from gh-pr/1969/head into gh-pr/1969/base
Owner

@⁠joeypercia on GitHub · 2026-11-29 04:51 UTC · original
joeypercia:resource-slot-evict-without-table → main · +19 −4 · 1 files · 1 commits · closed without merging

Part of #1900 and #1936 (stalls that end in the +0x23cf683 watchdog); it fixes one cause of them, which may not be their only one.

What it changes

Slot eviction (slot_evict in resource.rs, which the submitting thread's sweep reaches through let_go_idle) held the texture table TEXTURES from picking its candidates to the end of the call. Under that lock it emptied their view slots (evict_slots → HostHeap::texture_slot_evicted), each under the slot's Made lock. Two other paths take the same locks in the other order, and the three together form a ring:

thread holds waits for
submitting thread: sweep → let_go_idle → slot_evict → evict_slots → texture_slot_evicted TEXTURES a slot's Made lock
view mirror (victory-views-*, victory-aside): HostHeap::mirror_inner → begun_before → placed_texture → texture_at that slot's Made lock PLACED_TEXTURES
list thread: texture_at → create_at_address → hand_out_resource (textures().insert) PLACED_TEXTURES TEXTURES

Once the three meet, nothing presents again, and 30 s later the title's watchdog writes to 0 (+0x23cf683).

Now the candidates are still picked under TEXTURES, but each one is pinned with object::add_ref_alive and Held, the way alias_of keeps a texture alive. One already being released is skipped. The table is then let go before any slot is touched. The slots are emptied and the host copies let go with only their own locks held. The pins are let go at the end, with no lock held, so a last reference can take TEXTURES again. What gets evicted, and when, doesn't change.

How it was tested

  • GPU and profile: RTX 4070 Ti 12 GB, Windows 11 26200, 32 GB RAM; Series X, DLSS off, release build, the retail title into the world with Enter pressed through the menus.
  • Before: on main 568c5e5, one run stalled 150 s in; frames had already reached 7.7–8.9 s before it. Thread stacks taken with cdb 21 s into the stall show the three threads in the table above, in those frames: five victory-records, two victory-views, victory-aside, the list threads and a resource release waiting behind them. The run then ended with the watchdog (0xc0000005 at +0x23cf683).
  • After: the ring is a timing race. A second main run under the same conditions entered the world and ran 4 min without it, so a handful of short runs can't show the fix working. The reason for the change is the stacks and the lock order read in the code, not a measured before/after rate. With this change the ring can't close: the submitting thread no longer waits for a Made lock while holding TEXTURES.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: yes, cargo test --locked -p victory-gpu on 098400f: 589 passed, 0 failed, 44 ignored.

Not tested: a long session or many runs with the change (to see the stalls stop), AMD, and 8 GB cards, where slot eviction runs much more often (#1644).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Searches for "deadlock", "lock order", texture_slot_evicted, mirror_inner, PLACED_TEXTURES and hand_out_resource found no PR or report of this ring. Related: #1644 (the cost of slot_evict on 8 GB cards) and #1763 (slot eviction on 8 GB), which change what is evicted, not the locks.

Written with Claude Code (Claude Opus 5.5): it took the stacks, traced the lock ring through the code, wrote the change and this description, and ran the tests above.

**@⁠joeypercia** on GitHub · 2026-11-29 04:51 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1969) `joeypercia:resource-slot-evict-without-table` → `main` · +19 −4 · 1 files · 1 commits · closed without merging Part of #1900 and #1936 (stalls that end in the +0x23cf683 watchdog); it fixes one cause of them, which may not be their only one. ## What it changes Slot eviction (`slot_evict` in `resource.rs`, which the submitting thread's `sweep` reaches through `let_go_idle`) held the texture table `TEXTURES` from picking its candidates to the end of the call. Under that lock it emptied their view slots (`evict_slots` → `HostHeap::texture_slot_evicted`), each under the slot's `Made` lock. Two other paths take the same locks in the other order, and the three together form a ring: | thread | holds | waits for | |---|---|---| | submitting thread: `sweep` → `let_go_idle` → `slot_evict` → `evict_slots` → `texture_slot_evicted` | `TEXTURES` | a slot's `Made` lock | | view mirror (`victory-views-*`, `victory-aside`): `HostHeap::mirror_inner` → `begun_before` → `placed_texture` → `texture_at` | that slot's `Made` lock | `PLACED_TEXTURES` | | list thread: `texture_at` → `create_at_address` → `hand_out_resource` (`textures().insert`) | `PLACED_TEXTURES` | `TEXTURES` | Once the three meet, nothing presents again, and 30 s later the title's watchdog writes to 0 (`+0x23cf683`). Now the candidates are still picked under `TEXTURES`, but each one is pinned with `object::add_ref_alive` and `Held`, the way `alias_of` keeps a texture alive. One already being released is skipped. The table is then let go before any slot is touched. The slots are emptied and the host copies let go with only their own locks held. The pins are let go at the end, with no lock held, so a last reference can take `TEXTURES` again. What gets evicted, and when, doesn't change. ## How it was tested - GPU and profile: RTX 4070 Ti 12 GB, Windows 11 26200, 32 GB RAM; Series X, DLSS off, release build, the retail title into the world with Enter pressed through the menus. - Before: on `main` `568c5e5`, one run stalled 150 s in; frames had already reached 7.7–8.9 s before it. Thread stacks taken with `cdb` 21 s into the stall show the three threads in the table above, in those frames: five `victory-records`, two `victory-views`, `victory-aside`, the list threads and a resource release waiting behind them. The run then ended with the watchdog (`0xc0000005` at `+0x23cf683`). - After: the ring is a timing race. A second `main` run under the same conditions entered the world and ran 4 min without it, so a handful of short runs can't show the fix working. The reason for the change is the stacks and the lock order read in the code, not a measured before/after rate. With this change the ring can't close: the submitting thread no longer waits for a `Made` lock while holding `TEXTURES`. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: yes, `cargo test --locked -p victory-gpu` on `098400f`: 589 passed, 0 failed, 44 ignored. **Not tested:** a long session or many runs with the change (to see the stalls stop), AMD, and 8 GB cards, where slot eviction runs much more often (#1644). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Searches for "deadlock", "lock order", `texture_slot_evicted`, `mirror_inner`, `PLACED_TEXTURES` and `hand_out_resource` found no PR or report of this ring. Related: #1644 (the cost of `slot_evict` on 8 GB cards) and #1763 (slot eviction on 8 GB), which change what is evicted, not the locks. Written with Claude Code (Claude Opus 5.5): it took the stacks, traced the lock ring through the code, wrote the change and this description, and ran the tests above.
Slot eviction (`slot_evict`, under `let_go_idle` in the submitting
thread's sweep) held the texture table (`TEXTURES`) from picking its
candidates to the end, and under it emptied their view slots, each under
its `Made` lock. A view mirror (`HostHeap::mirror_inner`) holds a slot's
`Made` lock while it looks a texture up (`begun_before` ->
`placed_texture` -> `texture_at`, which takes `PLACED_TEXTURES`), and a
list thread making a placed texture holds `PLACED_TEXTURES` while it adds
it to `TEXTURES` (`create_at_address` -> `hand_out_resource`). That is a
ring of three locks: on an RTX 4070 Ti (main 568c5e5) presents stopped
for good 150 s into a run and the title's watchdog ended it (+0x23cf683);
the thread stacks taken during the stall show each of the three threads
waiting on the next one's lock.

The candidates are now pinned (`add_ref_alive`, `Held`, as `alias_of`
does) under the table's lock, the table is let go, and their slots and
host copies are let go with only their own locks held. The pins are let
go at the end, with no lock held.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 04:53:19 +00:00
github-bot closed this pull request 2026-11-29 04:53:19 +00:00
Author
Owner

@⁠joeypercia on GitHub · 2026-11-29 04:52 UTC · original

Closing as a duplicate: #1763 already lets the texture table go before evict_slots, which breaks the lock ring described above. The stacks and the lock order are now on #1763. (Claude Code, Claude Opus 5.5.)

**@⁠joeypercia** on GitHub · 2026-11-29 04:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1969#issuecomment-7250910102) Closing as a duplicate: #1763 already lets the texture table go before `evict_slots`, which breaks the lock ring described above. The stacks and the lock order are now on #1763. (Claude Code, Claude Opus 5.5.)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1969
No description provided.