Diagnostics: count the title mapping changes and how long the lock was held #766

Closed
rostaddotcc wants to merge 1 commit from upstream-pr/766 into main
rostaddotcc commented 2026-11-25 06:49:46 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by rostaddotcc on 2026-11-25T06:49:46Z.


The 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: a Remapping guard 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.rs prints and resets them next to the write-watch askings line:

the title's mapping changes: 4326.0 a frame, the lock held 6040.6 ms a frame in all, the longest change 106.0 ms

Nothing changes with the feature off — the tuple gains its second field only under cfg(feature = "diagnostics"), and Drop is 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:

per frame
mapping changes 1 721–5 041
lock held, all changes together 3 844–8 020 ms
longest single change 46–175 ms
readers' summed wait, same windows 194–2 475 ms
frame 4 000–8 000 ms

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-gpu under Wine with vkd3d-proton serving d3d12 and Microsoft's d3dcompiler_47: 130 passed, 1 failed, 3 ignored. The failure is the platform one that fails on main too (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, and cargo xtask policy reports 171 files ok.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6598945265 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/766). Originally posted by [rostaddotcc](https://github.com/rostaddotcc) on 2026-11-25T06:49:46Z. --- The 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`: a `Remapping` guard 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.rs` prints and resets them next to the write-watch askings line: ``` the title's mapping changes: 4326.0 a frame, the lock held 6040.6 ms a frame in all, the longest change 106.0 ms ``` Nothing changes with the feature off — the tuple gains its second field only under `cfg(feature = "diagnostics")`, and `Drop` is 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: | per frame | | |---|---:| | mapping changes | 1 721–5 041 | | lock held, all changes together | 3 844–8 020 ms | | longest single change | 46–175 ms | | readers' summed wait, same windows | 194–2 475 ms | | frame | 4 000–8 000 ms | 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-gpu` under Wine with vkd3d-proton serving `d3d12` and Microsoft's `d3dcompiler_47`: **130 passed, 1 failed, 3 ignored**. The failure is the platform one that fails on `main` too (`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, and `cargo xtask policy` reports 171 files ok.
upstream-sync closed this pull request 2026-11-25 19:09:29 +00:00
rostaddotcc commented 2026-11-25 19:09:45 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by rostaddotcc on 2026-11-25T18:20:32Z.


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 the diagnostics feature, printed next to the write-watch line in host.rs. crates/victory-gpu/src/framelog.rs in a2537066 has T::Remaps, T::RemapUs and T::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 8dd30ab the 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 on 9376fd6 against 0.0 in 136 of 136 windows with the diff.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7170775419 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/766#issuecomment-7170775419). Originally posted by [rostaddotcc](https://github.com/rostaddotcc) on 2026-11-25T18:20:32Z. --- 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 the `diagnostics` feature, printed next to the write-watch line in `host.rs`. `crates/victory-gpu/src/framelog.rs` in a2537066 has `T::Remaps`, `T::RemapUs` and `T::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 8dd30ab the 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 on 9376fd6 against 0.0 in 136 of 136 windows with the diff.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!766
No description provided.