Scratch chunks: 512 MiB kept on a PC of 32 GB, not 128 #182

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

@⁠mgrein on GitHub · 2026-11-30 20:21 UTC · original
mgrein:scratch-keep-512 → main · +46 −4 · 1 files · 47 commits · closed without merging

On a PC with 32 GB of RAM or less, residency::limited_host_ram() caps the spare scratch chunks at SPARE_MOST (128 MiB). The lists in the air hold more than that, so whatever came back past 128 MiB was dropped and then made again for the next lists. In the world of a new retail game at Series X 1440p that was ~3 chunks a frame. Each one is a writeback_upload_buffer: a kernel allocation, made resident, with the driver waiting for the card (NtGdiDdDDIWaitForSynchronizationObjectFromCpu). That came to ~4 % of the list threads' busy time.

This keeps up to 512 MiB (SPARE_LIMITED) on such a PC, instead of 128. trim_spare_chunks still drops spares when memory runs short, and PCs above 32 GB keep the 1 GiB they had.

  • VICTORY_SCRATCH_KEEP_MB=<MiB> sets the cap on any PC.
  • VICTORY_SCRATCH_KEEP_MB=ab:<a>:<b> switches every 20 seconds and logs each switch (scratch-keep switch <unix ms> on|off), for an A/B inside one run.

Measured

RTX 4070, Ryzen 5 5600X, 32 GB RAM, Series X profile at 1440p, DLSS Quality, VICTORY_SUBMIT_SPLIT=1, VICTORY_ASK_FIRST=1, VICTORY_OFF_LINE=1. One 15-minute idle run in the world with =ab:128:512; neighbouring 20 s windows are paired:

per frame 128 MiB 512 MiB pairs
scratch chunks made (temporary counter, removed) 3.2 0.1 36 of 36 lower
list threads' translating (all threads, the VICTORY_THIN line) 147.7 ms 145.4 ms 32 of 44 lower
frame median 37.0 ms 36.7 ms 25 of 40 faster

The frame effect is small, since this is CPU spent beside the frame's critical path. The churn itself is gone.

cargo test -p victory-gpu --lib passes.

🤖 Generated with Claude Code

**@⁠mgrein** on GitHub · 2026-11-30 20:21 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/182) `mgrein:scratch-keep-512` → `main` · +46 −4 · 1 files · 47 commits · closed without merging On a PC with 32 GB of RAM or less, `residency::limited_host_ram()` caps the spare scratch chunks at `SPARE_MOST` (128 MiB). The lists in the air hold more than that, so whatever came back past 128 MiB was dropped and then made again for the next lists. In the world of a new retail game at Series X 1440p that was ~3 chunks a frame. Each one is a `writeback_upload_buffer`: a kernel allocation, made resident, with the driver waiting for the card (`NtGdiDdDDIWaitForSynchronizationObjectFromCpu`). That came to ~4 % of the list threads' busy time. This keeps up to 512 MiB (`SPARE_LIMITED`) on such a PC, instead of 128. `trim_spare_chunks` still drops spares when memory runs short, and PCs above 32 GB keep the 1 GiB they had. - `VICTORY_SCRATCH_KEEP_MB=<MiB>` sets the cap on any PC. - `VICTORY_SCRATCH_KEEP_MB=ab:<a>:<b>` switches every 20 seconds and logs each switch (`scratch-keep switch <unix ms> on|off`), for an A/B inside one run. ## Measured RTX 4070, Ryzen 5 5600X, 32 GB RAM, Series X profile at 1440p, DLSS Quality, `VICTORY_SUBMIT_SPLIT=1`, `VICTORY_ASK_FIRST=1`, `VICTORY_OFF_LINE=1`. One 15-minute idle run in the world with `=ab:128:512`; neighbouring 20 s windows are paired: | per frame | 128 MiB | 512 MiB | pairs | |---|---|---|---| | scratch chunks made (temporary counter, removed) | 3.2 | 0.1 | 36 of 36 lower | | list threads' translating (all threads, the `VICTORY_THIN` line) | 147.7 ms | 145.4 ms | 32 of 44 lower | | frame median | 37.0 ms | 36.7 ms | 25 of 40 faster | The frame effect is small, since this is CPU spent beside the frame's critical path. The churn itself is gone. `cargo test -p victory-gpu --lib` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On a PC with 32 GB or less of memory (residency::limited_host_ram) the
spare scratch chunks were capped at 128 MiB, less than the lists in the
air hold: what came back past that was let go and made again for the
next lists, ~3 chunks a frame in the world at Series X 1440p, each a
kernel allocation that waits for the card (writeback upload memory made
resident), ~4 % of the list threads' busy time. Such a PC now keeps up
to 512 MiB; trim_spare_chunks still lets them go when memory runs short.

VICTORY_SCRATCH_KEEP_MB=<MiB> sets the cap on any PC; =ab:<a>:<b>
switches every 20 seconds and says so in the log.

Measured that way (40 neighbouring 20 s windows in the world, Series X
1440p DLSS Quality, SUBMIT_SPLIT, ASK_FIRST, OFF_LINE on; RTX 4070,
Ryzen 5 5600X, 32 GB): chunks made 3.2 -> 0.1 a frame (36 of 36 pairs),
the list threads' translating 2.9 ms a frame less in all (32 of 44),
frame median 0.4 ms less (25 of 40).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:25:21 +00:00
github-bot closed this pull request 2026-12-01 01:10:22 +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/182#issuecomment-7297692914) 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.