Diagnostics: count the title mapping changes and how long the lock was held #766
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/fxceless--victory-fork!766
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/766/head"
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?
@rostaddotcc on GitHub · 2026-11-25 06:49 UTC · original
rostaddotcc:diag/mapping-lock-counter→main· +49 −2 · 2 files · 1 commits · closed without mergingThe texture lane's line in the frame log counts readers waiting for the mapping lock. Nothing counts the writer that holds it, which is the number a decision about that lock needs — and it turns out to be the whole frame.
What this adds
Under the diagnostics feature only, in
watch.rs: aRemappingguard now records how long it was held, and three counters keep the count of the runtime's mapping changes, the microseconds held in all of them, and the longest single change.host.rsprints and resets them next to the write-watch askings line:Nothing changes with the feature off — the tuple gains its second field only under
cfg(feature = "diagnostics"), andDropis empty otherwise.What it measured (Linux/Proton, RX 7900 XT, RADV, vkd3d-proton 3.2.0)
A 400-second streaming run, the windows of the last two minutes:
So the title remaps thousands of times a frame in short changes of about 1.5 ms, and the lock is held for most of the frame. That is why the reader lane waits whenever it looks: there is rarely a moment when the lock is free, and neither side was measuring the contention — this makes the writer half visible.
It also explains the two things about the reader side that were already known: the wait is not one long remap that could be interrupted (it is thousands of short ones, so a reader waits for the change in flight, not for a burst to end), and why scoping the lock to ranges (#175) removes the wait entirely rather than just shortening it — a reader's own range is being remapped only in the change that touches it.
Tests
victory-gpuunder Wine with vkd3d-proton servingd3d12and Microsoft'sd3dcompiler_47: 130 passed, 1 failed, 3 ignored. The failure is the platform one that fails onmaintoo (pipeline::library::tests::a_rejected_blob_gives_an_empty_library, vkd3d-proton refuses the garbage blob where D3D12 returns an empty library). Release build without the diagnostics feature compiles clean, andcargo xtask policyreports 171 files ok.@rostaddotcc on GitHub · 2026-11-25 18:20 UTC · original
Closing this: a2537066's frame log covers the same three numbers, and better.
The counters here were a separate
REMAPS: [AtomicU64; 3](changes, microseconds held, longest) behind thediagnosticsfeature, printed next to the write-watch line inhost.rs.crates/victory-gpu/src/framelog.rsina2537066hasT::Remaps,T::RemapUsandT::RemapWaitUs— calls, time from asking for the lock to letting it go, and of that the readers' wait — per frame, in the frame log, alongside copies, copy-back, submissions and the card's idle time.It is on in diagnostics builds and toggled with
VICTORY_FRAME_LOG, so nothing has to be merged for the measurement to be available. Duplicating it in a second print line would only give two sources for the same numbers.What the counters found here, for the record, since it is the reason they existed: on
8dd30abthe write lock was held across the whole map operation — 1 721–5 041 mapping changes per frame, lock held 3 844–8 020 ms of each frame, longest single change 46–175 ms, with readers' summed wait 194–2 475 ms. That is what led to #175 (range-scoped locks), which is where the fix lives. #175 measures 430.6 ms median / 2 977.7 max of texture wait on9376fd6against 0.0 in 136 of 136 windows with the diff.Pull request closed