GPU: the pass over byte-copied descriptor records takes its lock once a page and a cheap fingerprint (36 to 24 ms a frame) #774

Closed
sagouindupm wants to merge 1 commit from upstream-pr/774 into main
sagouindupm commented 2026-11-25 07:14:17 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by sagouindupm on 2026-11-25T07:14:17Z.


What

The pass over descriptor records the title copies into its heap as bytes (sync_heaps, new in a26859f) compares a page's slots under one lock and with a cheap fingerprint. What is mirrored, and when, is unchanged.

Why

On an i5-12400F in the Series S world its own counter read 35.6 to 39.3 ms a frame (about 180,000 slots looked at, about 38,000 mirrored), and the settled frame was about 20 ms longer than with VICTORY_HEAP_SYNC=0 (numbers in #616). For each slot looked at it took the heap's fingerprint lock and hashed the 32-byte record with BLAKE3; most slots on a changed page have not changed.

How

crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/descriptor.rs:

  • HostHeap::mirror_copied takes a page's records as an iterator: the fingerprints are compared under one lock for the page, the changed slots are then mirrored as before (outside that lock, as before).
  • fingerprint: word by word, each step a rotation, an exclusive or with the word and a multiplication by an odd number. Every step is a bijection of the state, so two records of one length that differ in a single 8-byte word never share a fingerprint; others share one with the chance of any 64-bit hash, which is what the first 8 bytes of BLAKE3 gave. It is never 0 ("never looked at"), and the length is mixed in.
  • The rule itself (record_changed: not the one last seen; a never-seen empty slot stays as it was) is now a function of its own with a test.

Measured

RTX 3050 8 GB, i5-12400F, Windows 11, release build, Series S, first room of the world, VICTORY_TEXTURE_DROP_MIPS=1. Tree: a26859f + #188 + #640 + #610 + #467 + #518 + #51, with and without this commit. The pass's own line, last three of a five-minute run each:

Slots looked at a frame Mirrored a frame Pass, ms a frame
before 180,880; 198,575; 180,000 37,063; 37,515; 40,778 39.3; 37.7; 35.6
with this PR 184,435; 193,455; 213,747 35,727; 42,025; 38,659 21.6; 24.8; 24.1

Settled frame time (last five readings of the window title): 264, 260, 260, 248, 266 ms before; 239, 237, 249, 248, 251 ms with it. One run each, so the frame times are an indication; the pass's own counter is the measurement. The first room's walls and the picture are as before.

What is left in the pass (about 24 ms) is the mirroring of the about 38,000 records that did change and the reads of the pages; not touched here.

cargo test --release -p victory-gpu --lib on a26859f + this commit: 139 passed, 0 failed, 3 ignored (2 new: the change rule; every single-bit change of a 12-, 16- and 32-byte record gives another fingerprint).

Not tested: Series X, AMD and Intel cards, Linux/Proton, runs longer than five minutes.

AI-assisted: Claude Code (Claude Fable 5.2) wrote the change and ran the measurements, under my direction.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6599281763 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/774). Originally posted by [sagouindupm](https://github.com/sagouindupm) on 2026-11-25T07:14:17Z. --- ## What The pass over descriptor records the title copies into its heap as bytes (`sync_heaps`, new in `a26859f`) compares a page's slots under one lock and with a cheap fingerprint. What is mirrored, and when, is unchanged. ## Why On an i5-12400F in the Series S world its own counter read 35.6 to 39.3 ms a frame (about 180,000 slots looked at, about 38,000 mirrored), and the settled frame was about 20 ms longer than with `VICTORY_HEAP_SYNC=0` (numbers in #616). For each slot looked at it took the heap's fingerprint lock and hashed the 32-byte record with BLAKE3; most slots on a changed page have not changed. ## How `crates/victory-gpu/src/descriptor/host.rs`, `crates/victory-gpu/src/descriptor.rs`: - `HostHeap::mirror_copied` takes a page's records as an iterator: the fingerprints are compared under one lock for the page, the changed slots are then mirrored as before (outside that lock, as before). - `fingerprint`: word by word, each step a rotation, an exclusive or with the word and a multiplication by an odd number. Every step is a bijection of the state, so two records of one length that differ in a single 8-byte word never share a fingerprint; others share one with the chance of any 64-bit hash, which is what the first 8 bytes of BLAKE3 gave. It is never 0 ("never looked at"), and the length is mixed in. - The rule itself (`record_changed`: not the one last seen; a never-seen empty slot stays as it was) is now a function of its own with a test. ## Measured RTX 3050 8 GB, i5-12400F, Windows 11, release build, Series S, first room of the world, `VICTORY_TEXTURE_DROP_MIPS=1`. Tree: `a26859f` + #188 + #640 + #610 + #467 + #518 + #51, with and without this commit. The pass's own line, last three of a five-minute run each: | | Slots looked at a frame | Mirrored a frame | Pass, ms a frame | |---|---|---|---| | before | 180,880; 198,575; 180,000 | 37,063; 37,515; 40,778 | 39.3; 37.7; 35.6 | | with this PR | 184,435; 193,455; 213,747 | 35,727; 42,025; 38,659 | 21.6; 24.8; 24.1 | Settled frame time (last five readings of the window title): 264, 260, 260, 248, 266 ms before; 239, 237, 249, 248, 251 ms with it. One run each, so the frame times are an indication; the pass's own counter is the measurement. The first room's walls and the picture are as before. What is left in the pass (about 24 ms) is the mirroring of the about 38,000 records that did change and the reads of the pages; not touched here. `cargo test --release -p victory-gpu --lib` on `a26859f` + this commit: 139 passed, 0 failed, 3 ignored (2 new: the change rule; every single-bit change of a 12-, 16- and 32-byte record gives another fingerprint). Not tested: Series X, AMD and Intel cards, Linux/Proton, runs longer than five minutes. AI-assisted: Claude Code (Claude Fable 5.2) wrote the change and ran the measurements, under my direction.
iGoldenNinja commented 2026-11-25 08:09:04 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by iGoldenNinja on 2026-11-25T07:47:28Z.


Independent RTX 5080 result on Windows 11 Pro 25H2 build 26200.9974, driver 617.14, Ryzen 9 5900X and 32 GB RAM. I compared base a26859f with PR head 0941c0d in the same Series X diagnostics replay with the default relay. Both started with zero shader-cache hits and reached controllable prison gameplay. The candidate reused the shared host pipeline library after it grew during the base run.

Median mirroring time fell from 57.15 to 36.31 ms/frame, with median mirrored records per frame falling from 48,168 to 44,950 across 257 and 261 periodic samples. PresentMon averaged 3.27 to 3.42 FPS over the five-minute route. P99 increased 523.28 to 558.55 ms and the worst interval increased 664.42 to 1,058.38 ms. The walls and ceiling rendered in both comparable interior views, with the same stepped shoulder artifact visible. DRED logged no removal. This was one run per build.

Replay and counters. OpenAI Codex (GPT-6) ran the replay and drafted this report.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156255779 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/774#issuecomment-7156255779). Originally posted by [iGoldenNinja](https://github.com/iGoldenNinja) on 2026-11-25T07:47:28Z. --- Independent RTX 5080 result on Windows 11 Pro 25H2 build 26200.9974, driver 617.14, Ryzen 9 5900X and 32 GB RAM. I compared base `a26859f` with PR head `0941c0d` in the same Series X diagnostics replay with the default relay. Both started with zero shader-cache hits and reached controllable prison gameplay. The candidate reused the shared host pipeline library after it grew during the base run. Median mirroring time fell from **57.15 to 36.31 ms/frame**, with median mirrored records per frame falling from **48,168 to 44,950** across 257 and 261 periodic samples. PresentMon averaged **3.27 to 3.42 FPS** over the five-minute route. P99 increased **523.28 to 558.55 ms** and the worst interval increased **664.42 to 1,058.38 ms**. The walls and ceiling rendered in both comparable interior views, with the same stepped shoulder artifact visible. DRED logged no removal. This was one run per build. [Replay and counters](https://github.com/iGoldenNinja/victory-fork/blob/c42dde15626433a7420f66ccd55d6f6305a0758e/docs/ssd-pr774-5080.md). OpenAI Codex (GPT-6) ran the replay and drafted this report.
upstream-sync closed this pull request 2026-11-25 09:08:37 +00:00
sagouindupm commented 2026-11-25 09:08:48 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by sagouindupm on 2026-11-25T08:22:19Z.


Superseded by 9376fd6 on main, which takes the same cheap fingerprint and goes further (draw-table slots left to their draws: the pass at about 3 ms a frame where this PR left it at about 24). Closing. @iGoldenNinja thank you for the independent run: 57 to 36 ms a frame of mirroring on your 5080 matches what I saw here.

AI-assisted: Claude Code.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156942724 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/774#issuecomment-7156942724). Originally posted by [sagouindupm](https://github.com/sagouindupm) on 2026-11-25T08:22:19Z. --- Superseded by `9376fd6` on `main`, which takes the same cheap fingerprint and goes further (draw-table slots left to their draws: the pass at about 3 ms a frame where this PR left it at about 24). Closing. @iGoldenNinja thank you for the independent run: 57 to 36 ms a frame of mirroring on your 5080 matches what I saw here. AI-assisted: Claude Code.

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!774
No description provided.