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

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

@⁠rostaddotcc on GitHub · 2026-11-25 06:49 UTC · original
rostaddotcc:diag/mapping-lock-counter → main · +49 −2 · 2 files · 1 commits · closed without merging

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.

**@⁠rostaddotcc** on GitHub · 2026-11-25 06:49 UTC · [original](https://github.com/fxceless/victory-fork/pull/766) `rostaddotcc:diag/mapping-lock-counter` → `main` · +49 −2 · 2 files · 1 commits · closed without merging 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.
The texture lane's frame line counts readers waiting for the mapping lock,
never the writer that holds it. This adds, under the diagnostics feature
only, a count of the runtime's changes per frame, the time the lock was held
in all of them, and the longest single change, printed next to the
write-watch askings line.

Measured on Linux/Proton (RX 7900 XT, RADV, vkd3d-proton 3.2.0) over a
streaming run: 1 721 to 5 041 changes a frame, the lock held 3 844 to
8 020 ms a frame in all, the longest single change 46 to 175 ms. The readers
wait for that: on the same windows their summed wait was 194 to 2 475 ms,
against a frame of 4 to 8 seconds.

No behaviour changes with the feature off.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:39 +00:00
github-bot closed this pull request 2026-11-26 03:50:39 +00:00
Author
Owner

@⁠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 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.

**@⁠rostaddotcc** on GitHub · 2026-11-25 18:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/766#issuecomment-7170775419) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.