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
github-bot wants to merge 1 commit from gh-pr/774/head into gh-pr/774/base
Owner

@⁠sagouindupm on GitHub · 2026-11-25 07:14 UTC · original
sagouindupm:heap-sync-fast → main · +117 −31 · 2 files · 1 commits · closed without merging

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.

**@⁠sagouindupm** on GitHub · 2026-11-25 07:14 UTC · [original](https://github.com/fxceless/victory-fork/pull/774) `sagouindupm:heap-sync-fast` → `main` · +117 −31 · 2 files · 1 commits · closed without merging ## 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.
sync_heaps looked at about 180,000 slots a frame in the world, and for each took the heap's fingerprint lock and hashed its 32-byte record with BLAKE3: 35.6 ms a frame on an i5-12400F (its own counter), the frame about 20 ms longer than with VICTORY_HEAP_SYNC=0.

The slots of a page are now compared under one lock, and the fingerprint is four multiply steps (each a bijection of the state, so records one word apart never share one). What is mirrored, and when, is unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:51 +00:00
github-bot closed this pull request 2026-11-26 03:50:51 +00:00
Author
Owner

@⁠iGoldenNinja on GitHub · 2026-11-25 07:47 UTC · original

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.

**@⁠iGoldenNinja** on GitHub · 2026-11-25 07:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/774#issuecomment-7156255779) 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.
Author
Owner

@⁠sagouindupm on GitHub · 2026-11-25 08:22 UTC · original

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.

**@⁠sagouindupm** on GitHub · 2026-11-25 08:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/774#issuecomment-7156942724) 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

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