Preludes recorded on a thread of their own #89

Closed
github-bot wants to merge 0 commits from github-bot/gh-89 into main AGit
Owner

@⁠mgrein on GitHub · 2026-11-30 10:37 UTC · original
mgrein:prelude-away → main · +190 −32 · 1 files · 47 commits · closed without merging

Each of the title's lists that changes a texture's state gets a prelude list at submission (state transitions, twin copies, prelude uploads). In the world of a new retail game that's about 226 preludes a frame. Recording one costs ~16 µs in the driver: allocator reset, list reset, barriers and close. A profile of the submitting thread put this at 8 % (≈3.6 ms a frame), all on the thread the frame waits for.

The fix splits HostList::prelude in two:

  • prelude_work decides the prelude at submission, in order, exactly as before. The textures' real states still move there.
  • PreludeWork::record does the driver work. With VICTORY_PRELUDE_AWAY on (the default), that runs on a thread kept for it (victory-prelude) while the submitting thread goes on with the next lists, the refreshes and the card copies.

The lists get a placeholder for their prelude. The placeholder is filled right before the lists are sent: by the sending thread under VICTORY_SUBMIT_SPLIT, or by the submitting thread otherwise. The barriers borrow their resources, so the work holds Arcs of every texture it names until it has been recorded.

A submission that contains the same list twice records its preludes in place, as before. That list has one prelude, and it can't be recorded twice at once. A failed recording still ends in fail, on the waiting thread.

  • VICTORY_PRELUDE_AWAY=0 records them where they are decided, as before.
  • VICTORY_PRELUDE_AWAY=ab switches on and off every 20 seconds and logs each switch (prelude-away switch <unix ms> on|off), for an A/B inside one run.

Measured

RTX 4070, Ryzen 5 5600X, Series S profile, DLSS quality + frame generation, with VICTORY_SUBMIT_SPLIT=1, VICTORY_ASK_FIRST=1 and VICTORY_OFF_LINE=1. One 10-minute idle run in the world with VICTORY_PRELUDE_AWAY=ab. Neighbouring 20 s windows are paired (they see nearly the same scene):

pairs faster with it on median difference
submitting thread per frame 23 of 26 about −2 ms (the first pair is loading)
frame median 22 of 26 about −1 ms

No picture or log problems in the run. cargo test -p victory-gpu --lib passes.

🤖 Generated with Claude Code

**@⁠mgrein** on GitHub · 2026-11-30 10:37 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/89) `mgrein:prelude-away` → `main` · +190 −32 · 1 files · 47 commits · closed without merging Each of the title's lists that changes a texture's state gets a prelude list at submission (state transitions, twin copies, prelude uploads). In the world of a new retail game that's about 226 preludes a frame. Recording one costs ~16 µs in the driver: allocator reset, list reset, barriers and close. A profile of the submitting thread put this at 8 % (≈3.6 ms a frame), all on the thread the frame waits for. The fix splits `HostList::prelude` in two: - `prelude_work` decides the prelude at submission, in order, exactly as before. The textures' real states still move there. - `PreludeWork::record` does the driver work. With `VICTORY_PRELUDE_AWAY` on (the default), that runs on a thread kept for it (`victory-prelude`) while the submitting thread goes on with the next lists, the refreshes and the card copies. The lists get a placeholder for their prelude. The placeholder is filled right before the lists are sent: by the sending thread under `VICTORY_SUBMIT_SPLIT`, or by the submitting thread otherwise. The barriers borrow their resources, so the work holds `Arc`s of every texture it names until it has been recorded. A submission that contains the same list twice records its preludes in place, as before. That list has one prelude, and it can't be recorded twice at once. A failed recording still ends in `fail`, on the waiting thread. - `VICTORY_PRELUDE_AWAY=0` records them where they are decided, as before. - `VICTORY_PRELUDE_AWAY=ab` switches on and off every 20 seconds and logs each switch (`prelude-away switch <unix ms> on|off`), for an A/B inside one run. ## Measured RTX 4070, Ryzen 5 5600X, Series S profile, DLSS quality + frame generation, with `VICTORY_SUBMIT_SPLIT=1`, `VICTORY_ASK_FIRST=1` and `VICTORY_OFF_LINE=1`. One 10-minute idle run in the world with `VICTORY_PRELUDE_AWAY=ab`. Neighbouring 20 s windows are paired (they see nearly the same scene): | | pairs faster with it on | median difference | |---|---|---| | submitting thread per frame | 23 of 26 | about −2 ms (the first pair is loading) | | frame median | 22 of 26 | about −1 ms | No picture or log problems in the run. `cargo test -p victory-gpu --lib` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Each of the title's lists that changes a texture's state gets a prelude
list, about 226 a frame in the world, and recording one (allocator and
list reset, barriers, close) is ~16 us in the driver: 8 % of the
submitting thread. The prelude is still decided at submission, in order
(the textures' states move there), but recorded by a thread kept for
it while the submitting thread goes on; the lists wait for their
preludes only when they are sent (by the sending thread with
VICTORY_SUBMIT_SPLIT). Not for a submission that has a list twice.

VICTORY_PRELUDE_AWAY=0 records them where they are decided, as before;
=ab switches every 20 seconds and says so in the log, for a comparison
inside one run.

Measured that way (26 neighbouring 20 s windows in the world, SUBMIT_SPLIT,
ASK_FIRST and OFF_LINE on; RTX 4070, Ryzen 5 5600X): the submitting
thread ~2 ms a frame less (23 of 26 pairs), frame median ~1 ms less
(22 of 26 pairs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 10:38:21 +00:00
Author
Owner

@⁠kodifan on GitHub · 2026-11-30 12:57 UTC · original

Context: RTX 5060 Ti 16 GB, Ryzen 7 7700 (32 MB L3), 32 GB DDR5-6000, Windows 11 26200, driver 621.24. foxhound v0.8.2, Series S, DLSS Quality, Frame Generation on, 30 fps target. Measured from the layer's own per-frame lines.

Rendered frame 44.0 ms at 5,990 draws (21 fps), 57.7-60.7 ms at 8,744 draws (16 fps). The submitting thread is the whole frame: 39.3 / 40.4 / 43.0 / 48.2 ms - about 5.5-6.7 us per draw - with the card 84-89 % busy and idle 5.1-9.8 ms a frame behind it.

The lists' steps are the largest single item on that thread:

preparing per frame, the submitting thread: 39.3 ms ... 15.1 in the lists' steps
(refreshes 9.3 in 37 flushes of 9482, 8363 of them known to copy nothing,
9001 on several threads ...)

and in a busier spot:

... 48.2 ms ... 19.8 in the lists' steps (refreshes 12.6 in 43 flushes of 7245,
6126 of them known to copy nothing ...)

That is 15-20 ms of a 39-48 ms thread, so if ~226 preludes a frame at ~16 us each is right, moving their recording off the thread should show up plainly here - 3-4 ms, i.e. 7-9 % of the frame on this CPU.

Related and possibly a bigger win: 85-88 % of the slots scanned per frame are "known to copy nothing" (8,363 of 9,482; 6,126 of 7,245). If that scan can be skipped or kept as a compact list between frames, it looks like more than the preludes.

Happy to build and test this branch on the same save and spot and report the same numbers before and after.

**@⁠kodifan** on GitHub · 2026-11-30 12:57 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/89#issuecomment-7279149949) Context: RTX 5060 Ti 16 GB, Ryzen 7 7700 (32 MB L3), 32 GB DDR5-6000, Windows 11 26200, driver 621.24. foxhound v0.8.2, Series S, DLSS Quality, Frame Generation on, 30 fps target. Measured from the layer's own per-frame lines. Rendered frame 44.0 ms at 5,990 draws (21 fps), 57.7-60.7 ms at 8,744 draws (16 fps). The submitting thread is the whole frame: 39.3 / 40.4 / 43.0 / 48.2 ms - about 5.5-6.7 us per draw - with the card 84-89 % busy and idle 5.1-9.8 ms a frame behind it. The lists' steps are the largest single item on that thread: ``` preparing per frame, the submitting thread: 39.3 ms ... 15.1 in the lists' steps (refreshes 9.3 in 37 flushes of 9482, 8363 of them known to copy nothing, 9001 on several threads ...) ``` and in a busier spot: ``` ... 48.2 ms ... 19.8 in the lists' steps (refreshes 12.6 in 43 flushes of 7245, 6126 of them known to copy nothing ...) ``` That is 15-20 ms of a 39-48 ms thread, so if ~226 preludes a frame at ~16 us each is right, moving their recording off the thread should show up plainly here - 3-4 ms, i.e. 7-9 % of the frame on this CPU. Related and possibly a bigger win: **85-88 % of the slots scanned per frame are "known to copy nothing"** (8,363 of 9,482; 6,126 of 7,245). If that scan can be skipped or kept as a compact list between frames, it looks like more than the preludes. Happy to build and test this branch on the same save and spot and report the same numbers before and after.
github-bot closed this pull request 2026-12-01 01:10:33 +00:00
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-12-01 01:36 UTC · original

A note on why this shows as closed: GitHub closed every open pull request by itself when main's history was rewritten on 2026-12-01 (text-only changes; every commit hash changed), and they cannot be reopened. This is not a rejection.

Your change is in the batch being tested for the next release, carried over as one commit with you as its author. Nothing is needed from you now; the result will be posted here.

**@⁠readmet3xt-lab** on GitHub · 2026-12-01 01:36 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/89#issuecomment-7297691217) A note on why this shows as closed: GitHub closed every open pull request by itself when main's history was rewritten on 2026-12-01 (text-only changes; every commit hash changed), and they cannot be reopened. This is not a rejection. Your change is in the batch being tested for the next release, carried over as one commit with you as its author. Nothing is needed from you now; the result will be posted here.

Pull request closed

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