Check a heap page's descriptor records under one lock #7

Closed
github-bot wants to merge 5 commits from gh-pr/7/head into gh-pr/7/base
Owner

@⁠TaynanGT on GitHub · 2026-11-25 08:59 UTC · original
TaynanGT:claude/heap-sync-cost → local/fxceless-render · +102 −6 · 3 files · 5 commits · closed without merging

What and why

The raw descriptor sync (7b3da40) runs before every submission: it reads each changed 64 KiB page of the placed shader-visible heaps and mirrors the records the title copied there as bytes. In the first room that is 110 to 140 pages and 35,000 to 41,000 changed records a frame, 30 to 50 ms on the submitting thread, which bounds the frame rate.

For each page it called mirror_copied for all 2,048 records, locking the host heap's made and copied tables per record, though most records of a written page are unchanged. mirror_copied_run now compares the page's records with the kept ones under one lock and mirrors only those that changed.

Full write-up: docs/descriptor-sync.md.

Results

First room, 25 s per run after the room is steady:

Base Build FPS ms/frame Sync ms/frame
2146f54 without 6.5 155 38
2146f54 with 7.1 141 29
77e1ac7 without (2 runs) 6.6, 7.2 152, 139 38, 36
77e1ac7 with (2 runs) 7.0, 7.0 143, 144 30, 32

The sync is 5 to 9 ms a frame cheaper in every pair; on 77e1ac7 the FPS difference is within the run-to-run spread.

For scale, the whole sync, measured in one session with live switches (#10; three cycles of 20 s, 49 one-second samples per state, 77c3019): 6.7 FPS / 148.5 ms with it, 8.2 FPS / 121.8 ms without. The sync was written for missing walls and roofs (fxceless/victory-fork#305) and has not been shown to fix them yet; the captures of both states in the first room look the same. Whether it should stay on by default is left open here.

Tests

  • cargo test --release -p victory-gpu: 253 passed, 9 ignored, including records_copied_as_bytes_are_made_at_the_next_sync (copy, replace, remove) and raw_heap_sync_stops_before_dynamic_host_slots.
  • cargo clippy clean; asset policy: 192 files ok. CI green.

🤖 Generated with Claude Code

**@⁠TaynanGT** on GitHub · 2026-11-25 08:59 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/7) `TaynanGT:claude/heap-sync-cost` → `local/fxceless-render` · +102 −6 · 3 files · 5 commits · closed without merging ## What and why The raw descriptor sync (`7b3da40`) runs before every submission: it reads each changed 64 KiB page of the placed shader-visible heaps and mirrors the records the title copied there as bytes. In the first room that is 110 to 140 pages and 35,000 to 41,000 changed records a frame, 30 to 50 ms on the submitting thread, which bounds the frame rate. For each page it called `mirror_copied` for all 2,048 records, locking the host heap's `made` and `copied` tables per record, though most records of a written page are unchanged. `mirror_copied_run` now compares the page's records with the kept ones under one lock and mirrors only those that changed. Full write-up: [`docs/descriptor-sync.md`](../blob/claude/heap-sync-cost/docs/descriptor-sync.md). ## Results First room, 25 s per run after the room is steady: | Base | Build | FPS | ms/frame | Sync ms/frame | |---|---|---|---|---| | `2146f54` | without | 6.5 | 155 | 38 | | `2146f54` | with | 7.1 | 141 | 29 | | `77e1ac7` | without (2 runs) | 6.6, 7.2 | 152, 139 | 38, 36 | | `77e1ac7` | with (2 runs) | 7.0, 7.0 | 143, 144 | 30, 32 | The sync is 5 to 9 ms a frame cheaper in every pair; on `77e1ac7` the FPS difference is within the run-to-run spread. For scale, the whole sync, measured in one session with live switches (#10; three cycles of 20 s, 49 one-second samples per state, `77c3019`): 6.7 FPS / 148.5 ms with it, 8.2 FPS / 121.8 ms without. The sync was written for missing walls and roofs (fxceless/victory-fork#305) and has not been shown to fix them yet; the captures of both states in the first room look the same. Whether it should stay on by default is left open here. ## Tests - `cargo test --release -p victory-gpu`: 253 passed, 9 ignored, including `records_copied_as_bytes_are_made_at_the_next_sync` (copy, replace, remove) and `raw_heap_sync_stops_before_dynamic_host_slots`. - `cargo clippy` clean; asset policy: 192 files ok. CI green. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The raw descriptor sync reads each changed 64 KiB heap page and called
mirror_copied for each of its 2,048 records, locking the made and copied
tables per record, though most records of a written page are unchanged.
It now compares the page's records with the kept ones under one lock and
mirrors only those that changed.

In the first room the sync took 38 ms a frame on the submitting thread;
with this change 29 ms, and the frame rate went from 6.5 to 7.1 FPS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/descriptor-sync.md: what the sync does and why, its cost per frame
in the first room, the change in this branch with measurements on two
bases, VICTORY_HEAP_SYNC and its effect, the frame log line and the
tests that cover it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:57:29 +00:00
github-bot closed this pull request 2026-11-26 05:57:29 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 09:23 UTC · original

With local/fxceless-render at 77e1ac7 merged (28b69fb): cargo test --release -p victory-gpu 253 passed, 9 ignored; clippy clean. A live run on 77e1ac7 could not be measured: the game stayed on the account screen for 10 minutes (Enter, the stand-in pad's A, was pressed 17 times; 71a71a5 leaves it within about a minute), and after its window closed the process kept running until it was ended. The numbers above stay those of 2146f54.

**@⁠TaynanGT** on GitHub · 2026-11-25 09:23 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/7#issuecomment-7158275398) With `local/fxceless-render` at `77e1ac7` merged (`28b69fb`): `cargo test --release -p victory-gpu` 253 passed, 9 ignored; clippy clean. A live run on `77e1ac7` could not be measured: the game stayed on the account screen for 10 minutes (Enter, the stand-in pad's A, was pressed 17 times; `71a71a5` leaves it within about a minute), and after its window closed the process kept running until it was ended. The numbers above stay those of `2146f54`.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 12:49 UTC · original

Correction to my previous comment: 77e1ac7 is fine. Since it shows a stand-in window (class VIctory.title) and makes the title's own window message-only, my test scripts, which looked for the title's window class, sent no key and no close. With them fixed, 77e1ac7 leaves the account screen in 57 s and closes cleanly. A measurement on it is next.

**@⁠TaynanGT** on GitHub · 2026-11-25 12:49 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/7#issuecomment-7162904494) Correction to my previous comment: `77e1ac7` is fine. Since it shows a stand-in window (class `VIctory.title`) and makes the title's own window message-only, my test scripts, which looked for the title's window class, sent no key and no close. With them fixed, `77e1ac7` leaves the account screen in 57 s and closes cleanly. A measurement on it is next.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 13:06 UTC · original

Measured on 77e1ac7 (control) against 28b69fb (this branch with 77e1ac7 merged), first room, 25 s per run, runs alternated:

Run Build FPS ms/frame Sync ms/frame
1 control 6.6 152 38.4
2 this change 7.0 143 29.6
3 control 7.2 139 35.9
4 this change 7.0 144 32.2

The sync itself is 5 to 9 ms a frame cheaper in every pair. The frame rate difference (6.9 against 7.0 on average) is within the run-to-run spread of the control, so on this base the gain does not show in FPS.

**@⁠TaynanGT** on GitHub · 2026-11-25 13:06 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/7#issuecomment-7163293349) Measured on `77e1ac7` (control) against `28b69fb` (this branch with `77e1ac7` merged), first room, 25 s per run, runs alternated: | Run | Build | FPS | ms/frame | Sync ms/frame | |---|---|---|---|---| | 1 | control | 6.6 | 152 | 38.4 | | 2 | this change | 7.0 | 143 | 29.6 | | 3 | control | 7.2 | 139 | 35.9 | | 4 | this change | 7.0 | 144 | 32.2 | The sync itself is 5 to 9 ms a frame cheaper in every pair. The frame rate difference (6.9 against 7.0 on average) is within the run-to-run spread of the control, so on this base the gain does not show in FPS.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-25 19:21 UTC · original · edited 2026-11-25 20:01 UTC

Moved into #11, which holds all of this work on one branch, since merged into main.

**@⁠TaynanGT** on GitHub · 2026-11-25 19:21 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/7#issuecomment-7172179879) · edited 2026-11-25 20:01 UTC Moved into #11, which holds all of this work on one branch, since merged into `main`.

Pull request closed

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