Repository navigation
Conversation
…'s lock Every slot a draw binds looks its view up in VIEWS (`view_at` from `HostHeap::mirror`, `descriptor::view` from the table paths), each under the registry's lock, which title threads recording lists at once all wrote (as a mutex here; as a shared count once reads share it, Marvisak#2821). The registry entry a slot names keeps its view while its generation is current: an entry gets another view only after `forget` freed it under a new generation. So each entry's live generation (0 when free) is now kept in chunks of atomics, written under the registry's exclusive lock, and each thread keeps the views it looked up (entry, generation, view; 1024 slots by entry). A lookup whose entry is still live at that generation takes the thread's copy without the lock; others look it up as before. Test: a thread that looked views up finds a slot's new view once it is rewritten, and none for a released resource's view, also when its entry was given to another view since. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 26, 2026
|
WARP verification report (test report only, no code changes)
AI use: Claude Code (Claude Sonnet 5.5) |
Dukestar69
approved these changes
Nov 26, 2026
Dukestar69
left a comment
There was a problem hiding this comment.
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
- Caching
(entry, generation, View)in thread-localSEENvalidated against the lock-freeAcquire/Releasegeneration tableLIVE(updated underVIEWSinrecordand cleared to0inforget) cleanly avoidsVIEWSmutex contention on hot draw paths while preserving invalidation on release/reuse. cargo test -p victory-gpu --lib descriptor:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released(RTX 5090): 22 passed, 0 failed (includingthreads_that_looked_views_up_see_them_rewritten_and_released).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
gabrielcruzg3
added a commit
to gabrielcruzg3/victory-3060TI
that referenced
this pull request
Nov 26, 2026
…s/fences, heap pass fix) & playable presets
This was referenced Nov 26, 2026
gabrielcruzg3
added a commit
to gabrielcruzg3/victory-3060TI
that referenced
this pull request
Nov 26, 2026
…ip, batched card_before barriers, WaitOnAddress fences)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2586 (the cost of list methods on the title's threads). Local change, same behaviour. Second of two lock fixes for draws recorded on several threads at once. The first is #3274, which removes the most contended lock. This one is smaller and pays off mostly together with #2821.
The problem
Every slot a draw binds looks up its view in the view registry
descriptor::VIEWS:HostHeap::mirror→view_atfor the slots a table names, anddescriptor::viewon the table paths. Each lookup takes the registry's lock. On main that's a mutex. With #2821 it becomes anRwLockread, but readers still write the lock word's shared count, so the five recording threads bounce that cache line between cores. With main + #1978 + #2821 + #3258, a per-call-site lock counter put it second, afterTEXTURES_AT(#3274): six takes per draw, 157 ns on one thread and 439 ns each on five (ranking table in #3274).The change
A registry entry keeps its view for as long as its generation is current. An entry gets another view only after
forgethas freed it under a new generation. So:AtomicU32. The chunks are made as the list grows and never freed. They are written only under the registry's exclusive lock: when an entry gets a view inrecord, and whenforgetfrees it;Same answers as the locked lookup. A view released right after the check is the same race as a view released right after the locked lookup returns. Entries past 4,096 × 1,024 are never kept, so they are always looked up under the lock.
Tests
New:
descriptor::tests::threads_that_looked_views_up_see_them_rewritten_and_released. A second thread looks views up (and keeps them) while the main thread:I checked that the test catches the bug it's meant for: without the
set_live(i, 0)inforget, it fails at "released".--features diagnostics,VICTORY_D3D12_WARP=1)The failures are main's (see #3274). Clippy passes with
-D warningsfor the workspace, all targets, with and without--all-features.repository_passes_policypasses, and rustfmt is clean on the changed lines.Measured
Same method as #3274:
pipeline::list_bench's draw sequence on 1 and 5 threads, 7 runs per build interleaved round-robin, medians (ranges). RTX 4060 Laptop, i7-14650HX, release. Seven single-threaded CPU-bound processes I don't control ran throughout, which interleaving spreads evenly over the builds. ns per draw, per thread:Two more interleaved rounds gave, on five threads: with #3274 2893 → 2609 (5 runs) and 2803 → 2691 (7 runs); without it 4818 → 3784 (7 runs).
On main alone it changes nothing measurable: the other shared locks (
TEXTURES_AT, main's mutexes) dominate. Together with #2821 it saves about 0.5–1 µs per draw on five threads, and on top of #2821 + #3274 about 0.1–0.3 µs (−2 to −10%).Conflicts
The text conflicts with #2821, #2099, #3234 and #2848 (lines next to
view_at/view, or the registry's lock calls). With #2821: take this PR's bodies ofview_atandview, and inview_ofchangeVIEWS.lock()toVIEWS.read(). Without that change the merge doesn't compile, so nothing breaks silently. That is the measured tree.What this does not show
hostmutex plus itsArccount (six per draw), andshadow::BUFFERS(four per draw). Removing the mutex alone saved about 80 ns, so most of the remaining cost is the sharedArccounts. That one belongs with the host-copy lookup in GPU: a draw's texture read takes its host copy once, and its flags without asking the driver #3258.AI use: Claude Code (Claude Opus 5.5) profiled the locks, wrote the change and the test, and ran the benchmarks and test suites listed above; I reviewed the results.
🤖 Generated with Claude Code