Host-side performance & diagnostics findings: descriptor fingerprints, heap-view pass, and a 115 ms/frame lock #1149

Open
opened 2026-11-26 03:58:27 +00:00 by github-bot · 2 comments
Owner

@⁠liuycsbxbxn on GitHub · 2026-11-25 21:39 UTC · original

What this is — a measurement report, not a pull request. Two patches exist and are ready
(0001 tools, 0002 host performance); they are not attached here. Tell me whether you
want them as a PR and I will send them with git am-clean patches.

Where the numbers come from — one machine, one run each, diagnostics build:
Windows 11 · i9-14900KF · RTX 5080 32 GB · Series X profile · 1280×720 window.
Front-end changes are off by default unless noted below.

No game files, no logs with title data, no copyrighted material in this report.

Results at a glance

change before after
waiting on the descriptor-fingerprint mutex 28.9 ms/frame 0.97 ms/frame
heap buffer-view pass (round trip) 37.5 ms/frame 29.5 ms/frame
heap buffer-view pass (slot walk) 19.4 ms/frame 17.1 ms/frame
waiting on the RELEASING lock 115 ms/frame 0 (opt-in switch)
VICTORY_COPY_PLAIN=1 on the submitting thread 14.62 ms/frame 4.04 ms/frame
average frame, same profile 138.4–144.4 ms 128.8 ms

Two of those numbers (the lock waits) did not move frame time when removed — they are
contention, not critical path. That is itself the useful finding.

0001 — offline tools: name a shader, dump IR, count foldable patterns

Three additions to the offline tools, no runtime behaviour change.

  1. translate --warm <file> prints <hash> @0x… <archive name> for every container it
    takes. A run logs cost by pipeline hash; without this line a cost cannot be read back as a
    shader. This is how the cost/name table was produced — the top of which is
    MS_VS_PedTransformPreSkinD 7.4 ms/frame, CS_GenerateShadowMasks_Checkerboard_NoHair
    6–9 ms, MS_VS_CascadeShadows_draw 5.1 ms.

  2. VICTORY_DUMP_IR=<dir> writes the translated IR of each program as text;
    VICTORY_TRANSLATE_ONLY=<hash,…> (already existed) narrows a run to the shaders of
    interest. Three shaders: 0.4 s, 7,090 IR instructions.

  3. emit/bitcode/census.rs counts three foldable patterns in the emitted module —
    bitcast of bitcast, an extract of the same lane of the same value twice, and a
    select whose arms are one value or whose arm is chosen by a constant.

    Over all 25,636 programs / 95,055,345 instructions of shaders.rpf:

    pattern foldable total
    bitcast of bitcast 0 11,362,311
    repeated extract 4,058 6,221,994
    degenerate select 0 11,474,819

    Conclusion worth keeping: the existing clean-up passes already remove these. A peephole
    pass for them would find nothing
    — so nobody needs to write one. The counters stay as a
    regression guard (three extra columns in the census table).

0002 — host-side performance and lock diagnostics

  1. Descriptor fingerprints without the mutex (descriptor/host.rs): RwLock<Vec<AtomicU64>>
    instead of Mutex<Vec<u64>>, one atomic per record. Profile: waiting on that mutex
    28.9 → 0.97 ms/frame. Frame rate unchanged — the waiters were not the critical path;
    the change removes contention, not time.
  2. Heap buffer-view pass (draw.rs, host.rs):
    • a slot whose record still names the view its range was worked out from keeps that range
      (the 16-pass full rescan still re-reads them all) — 37.5 → 29.5 ms/frame (median of 62
      samples in one scene);
    • slots walked in slot order, since records sit at base + index * step — walk
      19.4 → 17.1 ms;
    • the pass is timed in three parts (walk / spans+refreshes / textures), skip count on the
      frame line. Measured skip rate 9–32%; the rest are descriptors the title really
      rewrites (about 12,000 a frame, 1.6 µs each including one host view creation), so 10 ms is
      out of reach this way.
  3. VICTORY_LOCK_STATS=1 (diagnostics): waits bucketed by mutex address, the five worst
    printed with the frame line. It found that one static lock, RELEASING in queue.rs,
    accounts for 115 ms/frame
    (3–4 waits of 28–43 ms) because it is held for a whole burst of
    parts.
  4. VICTORY_RELEASE_TRY=1 (off by default): a caller that finds another thread releasing
    returns at once, leaving its queues to that thread. The 115 ms of waiting drops to zero and
    the frame time does not move — again, the waiters were never the critical path. Left in
    as an experiment switch only.
  5. VICTORY_TEX_HASH_EVERY=<n> (default 8 = unchanged): interval of the guard's
    whole-texture hashes for view-memory textures. 16 halves the hashing for 0.75 ms/frame,
    at the cost of a longer window in which a write through another view goes unseen — so 8
    stays the default.

The one existing setting worth turning on

VICTORY_COPY_PLAIN=1 — a copy of title memory becomes rep movsb with an exception
handler that falls back to the kernel when a page is gone.

| submitting thread | default | `VICTORY_COPY_PLAIN=1

**@⁠liuycsbxbxn** on GitHub · 2026-11-25 21:39 UTC · [original](https://github.com/fxceless/victory-fork/issues/1149) > **What this is** — a measurement report, not a pull request. Two patches exist and are ready > (`0001` tools, `0002` host performance); they are **not attached here**. Tell me whether you > want them as a PR and I will send them with `git am`-clean patches. > > **Where the numbers come from** — one machine, one run each, `diagnostics` build: > Windows 11 · i9-14900KF · RTX 5080 32 GB · Series X profile · 1280×720 window. > Front-end changes are off by default unless noted below. > > No game files, no logs with title data, no copyrighted material in this report. ## Results at a glance | change | before | after | |---|---|---| | waiting on the descriptor-fingerprint mutex | 28.9 ms/frame | **0.97 ms/frame** | | heap buffer-view pass (round trip) | 37.5 ms/frame | **29.5 ms/frame** | | heap buffer-view pass (slot walk) | 19.4 ms/frame | **17.1 ms/frame** | | waiting on the `RELEASING` lock | 115 ms/frame | 0 (opt-in switch) | | `VICTORY_COPY_PLAIN=1` on the submitting thread | 14.62 ms/frame | **4.04 ms/frame** | | average frame, same profile | 138.4–144.4 ms | **128.8 ms** | Two of those numbers (the lock waits) **did not move frame time** when removed — they are contention, not critical path. That is itself the useful finding. ## 0001 — offline tools: name a shader, dump IR, count foldable patterns Three additions to the offline tools, no runtime behaviour change. 1. **`translate --warm <file>` prints `<hash> @0x… <archive name>`** for every container it takes. A run logs cost by pipeline hash; without this line a cost cannot be read back as a shader. This is how the cost/name table was produced — the top of which is `MS_VS_PedTransformPreSkinD` 7.4 ms/frame, `CS_GenerateShadowMasks_Checkerboard_NoHair` 6–9 ms, `MS_VS_CascadeShadows_draw` 5.1 ms. 2. **`VICTORY_DUMP_IR=<dir>`** writes the translated IR of each program as text; `VICTORY_TRANSLATE_ONLY=<hash,…>` (already existed) narrows a run to the shaders of interest. Three shaders: 0.4 s, 7,090 IR instructions. 3. **`emit/bitcode/census.rs` counts three foldable patterns** in the *emitted* module — `bitcast` of `bitcast`, an `extract` of the same lane of the same value twice, and a `select` whose arms are one value or whose arm is chosen by a constant. Over all 25,636 programs / 95,055,345 instructions of `shaders.rpf`: | pattern | foldable | total | |---|---|---| | bitcast of bitcast | **0** | 11,362,311 | | repeated extract | **4,058** | 6,221,994 | | degenerate select | **0** | 11,474,819 | **Conclusion worth keeping: the existing clean-up passes already remove these. A peephole pass for them would find nothing** — so nobody needs to write one. The counters stay as a regression guard (three extra columns in the census table). ## 0002 — host-side performance and lock diagnostics 1. **Descriptor fingerprints without the mutex** (`descriptor/host.rs`): `RwLock<Vec<AtomicU64>>` instead of `Mutex<Vec<u64>>`, one atomic per record. Profile: waiting on that mutex **28.9 → 0.97 ms/frame**. Frame rate unchanged — the waiters were not the critical path; the change removes contention, not time. 2. **Heap buffer-view pass** (`draw.rs`, `host.rs`): - a slot whose record still names the view its range was worked out from keeps that range (the 16-pass full rescan still re-reads them all) — **37.5 → 29.5 ms/frame** (median of 62 samples in one scene); - slots walked in slot order, since records sit at `base + index * step` — walk **19.4 → 17.1 ms**; - the pass is timed in three parts (walk / spans+refreshes / textures), skip count on the frame line. Measured skip rate **9–32%**; the rest are descriptors the title really rewrites (about 12,000 a frame, 1.6 µs each including one host view creation), so 10 ms is out of reach this way. 3. **`VICTORY_LOCK_STATS=1`** (diagnostics): waits bucketed by mutex address, the five worst printed with the frame line. It found that **one static lock, `RELEASING` in `queue.rs`, accounts for 115 ms/frame** (3–4 waits of 28–43 ms) because it is held for a whole burst of parts. 4. **`VICTORY_RELEASE_TRY=1`** (off by default): a caller that finds another thread releasing returns at once, leaving its queues to that thread. The 115 ms of waiting drops to zero and **the frame time does not move** — again, the waiters were never the critical path. Left in as an experiment switch only. 5. **`VICTORY_TEX_HASH_EVERY=<n>`** (default 8 = unchanged): interval of the guard's whole-texture hashes for view-memory textures. 16 halves the hashing for **0.75 ms/frame**, at the cost of a longer window in which a write through another view goes unseen — so 8 stays the default. ## The one existing setting worth turning on **`VICTORY_COPY_PLAIN=1`** — a copy of title memory becomes `rep movsb` with an exception handler that falls back to the kernel when a page is gone. | submitting thread | default | `VICTORY_COPY_PLAIN=1
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:27 +00:00
Author
Owner

@⁠spk-c on GitHub · 2026-11-26 01:08 UTC · original

The distinction between contention and critical-path cost is useful here. On our RTX 4090 / Ryzen 9 9950X3D / Windows 10 release reference (ad3f267), three consecutive periodic windows with zero pending pipelines showed:

Frame (ms) Preparing (ms) Buffer copy (ms) Heap pass (ms) Draws/frame
230.7 76.3 38.1 89.4 4079
209.4 55.6 28.8 38.3 3520
183.5 62.5 30.9 49.2 3365

#1231 adds VICTORY_HEAP_PROFILE=1 (off by default), splitting the buffer-heap work into descriptor scan/mirroring (including locks), grouping spans per shadow, and refresh. It complements the lock measurements here; it does not replace them. Reference notes.

These are changing streaming workloads, not controlled comparisons. The timers overlap, and heap wall time is not necessarily time on the frame's critical path. The instrumentation passed fork CI; a matched runtime phase comparison is still outstanding. AI-assisted analysis and implementation.

**@⁠spk-c** on GitHub · 2026-11-26 01:08 UTC · [original](https://github.com/fxceless/victory-fork/issues/1149#issuecomment-7179475591) The distinction between contention and critical-path cost is useful here. On our RTX 4090 / Ryzen 9 9950X3D / Windows 10 release reference (ad3f267), three consecutive periodic windows with zero pending pipelines showed: | Frame (ms) | Preparing (ms) | Buffer copy (ms) | Heap pass (ms) | Draws/frame | | ---: | ---: | ---: | ---: | ---: | | 230.7 | 76.3 | 38.1 | 89.4 | 4079 | | 209.4 | 55.6 | 28.8 | 38.3 | 3520 | | 183.5 | 62.5 | 30.9 | 49.2 | 3365 | #1231 adds `VICTORY_HEAP_PROFILE=1` (off by default), splitting the buffer-heap work into descriptor scan/mirroring (including locks), grouping spans per shadow, and refresh. It complements the lock measurements here; it does not replace them. [Reference notes](https://github.com/spk-c/victory-fork/blob/580b68d6bac7b22813b6b1f1d7a9fa82082085d6/diagnostics/HEAP_READBACK_BASELINE.md). These are changing streaming workloads, not controlled comparisons. The timers overlap, and heap wall time is not necessarily time on the frame's critical path. The instrumentation passed fork CI; a matched runtime phase comparison is still outstanding. AI-assisted analysis and implementation.
Author
Owner

@⁠liuycsbxbxn on GitHub · 2026-11-26 13:04 UTC · original

Thanks - that table is the right correction to make. Across three consecutive windows the heap pass moves 89.4 -> 38.3 -> 49.2 ms, so a single-scene median says less than it looks like it does.

What 37.5 -> 29.5 actually are: a paired A/B on the same scene and the same window sequence, median of 62 samples each side, one machine - the delta is comparable inside that run, not an absolute figure. Your 4090/9950X3D numbers put the absolute level far higher, which fits.

We agree on the critical-path point, and it is the same result the locks gave: removing 115 ms of RELEASING waits moved frame time by nothing. Heap wall time deserves the same suspicion, and #1231 splitting it into scan/mirroring (with locks), span grouping and refresh is exactly the instrument for the matched phase comparison you say is outstanding - I can't run it here (no dump, no card, Intel iGPU only), so my numbers only ever describe one scene on one machine.

Worth knowing when weighing CI too: on a clean fork of main the repo's own CI fails at the Clippy step before the tests (manual_is_multiple_of / dead-code), so red CI on this tree is not a signal about a change.

Still open from the report: would the two patches (0001 tools, 0002 host performance) be welcome as a PR, or better kept as switches in a fork?

**@⁠liuycsbxbxn** on GitHub · 2026-11-26 13:04 UTC · [original](https://github.com/fxceless/victory-fork/issues/1149#issuecomment-7192833990) Thanks - that table is the right correction to make. Across three consecutive windows the heap pass moves 89.4 -> 38.3 -> 49.2 ms, so a single-scene median says less than it looks like it does. What 37.5 -> 29.5 actually are: a paired A/B on the same scene and the same window sequence, median of 62 samples each side, one machine - the delta is comparable inside that run, not an absolute figure. Your 4090/9950X3D numbers put the absolute level far higher, which fits. We agree on the critical-path point, and it is the same result the locks gave: removing 115 ms of `RELEASING` waits moved frame time by nothing. Heap wall time deserves the same suspicion, and #1231 splitting it into scan/mirroring (with locks), span grouping and refresh is exactly the instrument for the matched phase comparison you say is outstanding - I can't run it here (no dump, no card, Intel iGPU only), so my numbers only ever describe one scene on one machine. Worth knowing when weighing CI too: on a clean fork of `main` the repo's own CI fails at the Clippy step before the tests (`manual_is_multiple_of` / dead-code), so red CI on this tree is not a signal about a change. Still open from the report: would the two patches (0001 tools, 0002 host performance) be welcome as a PR, or better kept as switches in a fork?
This discussion has been locked. Commenting is limited to contributors.
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/fxceless--victory-fork#1149
No description provided.