Skip to content

Switches for slow storage and low-memory Macs - #200

Merged
pragyaangaur merged 4 commits into
pragyaangaur:mainfrom
coltonbooth:feat/slow-storage-low-memory
Nov 26, 2026
Merged

pragyaangaur merged 4 commits into
pragyaangaur:mainfrom
coltonbooth:feat/slow-storage-low-memory

Conversation

@coltonbooth

Copy link
Copy Markdown
Contributor

Switches for Macs with slow storage or little memory, found while getting an 8 GB M1 Air (Series S, macOS 27.2.1) to the game world (#135). Builds on #152 (its two commits are the first two here). Everything is off unless set.

Switch What it does Measured on the 8 GB M1
VICTORY_NO_HANG_WATCHDOG=1 Turns the title's three jumps into its deliberate crash into 2-byte NOPs: the stale-heartbeat check (+0x2215bdc) and both forms of its 30-check "no finished frame" countdown (+0x2215c70, +0x2215d84). Known 1.0.2.1 build only, and only where the original bytes are found. No more crash at +0x2215c35 / +0x23cf683 (the one MaxNiftyNine hit on an M2 in #140) while the world loads slowly or its first frames take seconds
VICTORY_DSTORAGE_WORKERS=<n> DirectStorage reads in flight (default: one per core) +30–50% throughput from a network share at 32
VICTORY_EVICT_HEAP_UAV=1 Textures viewed for unordered access in shader-visible heaps may be given up while no shader has written through a heap. A null unordered texture view is made again for a draw reading it through a table (mirror's lazy path), and all of them before the submission of the first heap write (Host::execute). Host textures 1.7 GB → 0.15–0.3 GB; no heap write happened, nothing had to be made again
VICTORY_SPILL_SHADERS=1 Shader containers wait on disk (cache/shader-containers/, by BLAKE3) until translated, instead of in memory. Written under a temporary name and renamed; reused across runs. 19,000 containers, 224 MB out of memory
VICTORY_READ_STATS=1 Requests and bytes per title file (DirectStorage and ReadFile), the 30 most read every 30 s shaders.rpf alone: 105,000 ReadFile calls in 11 min; copying 15 GB of 109 files to local SSD removed ~74% of network reads

Tests

🤖 Generated with Claude Code

BoothFarm and others added 3 commits November 25, 2026 14:45
…lags

A memory's host texture takes the uses of every title texture there, so
streamed textures sharing memory with a render target got its flags, were
never uploaded and were never given up: 2 GB of them, viewed by heap slots
alone, on an 8 GB M1 (pragyaangaur#135). A texture now counts as GPU-written once a
list moves it to a render target, depth write or unordered access state,
or a heap slot gives shaders unordered access to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clwb faults under Rosetta, and each write-back loop cost an exception
through Wine: about 15,000 a second on the job threads during world load
(pragyaangaur#135). The clwb of each loop the emulator already recognises becomes a
NOP of its length before any title thread runs; the loop's add, cmp and
jbe stay, so its registers end as before. A PC's memory is coherent, so
the write-back had nothing to do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found on an 8 GB M1 with the game on a Wi-Fi NFS share backed by a
spinning disk (pragyaangaur#135): world streaming queued thousands of reads at about
20 MB/s, the title's hang watchdog killed it, and once it loaded, memory
ran out. All off unless set.

- VICTORY_NO_HANG_WATCHDOG=1: the title's three jumps to its deliberate
  crash (stale thread heartbeat, and both forms of its 30-check
  "no finished frame" countdown) become two-byte NOPs, on the known
  1.0.2.1 build only and only where the original bytes are found.
- VICTORY_DSTORAGE_WORKERS=<n>: DirectStorage reads in flight (default one
  per core); 32 gave a network share 30-50% more throughput.
- VICTORY_EVICT_HEAP_UAV=1: textures viewed for unordered access in
  shader-visible heaps may be given up while no shader has written
  through a heap (none did in this title's runs); an unordered texture
  view left null is made again for a draw reading it through a table,
  and all of them before the submission of the first heap write.
  Host textures fell from 1.7 GB to 0.15-0.3 GB.
- VICTORY_SPILL_SHADERS=1: shader containers wait on disk under the cache
  folder until translated instead of in memory (19,000 of them, 224 MB);
  written under a temporary name and renamed, reused across runs.
- VICTORY_READ_STATS=1: requests and bytes per title file (DirectStorage
  and ReadFile), the 30 most read every 30 s: which files to copy off a
  slow share.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pragyaangaur pragyaangaur added area:gpu Host GPU runtime: resources, copies, presenting area:title The game's own startup and runtime behaviour labels Nov 26, 2026
@pragyaangaur

Copy link
Copy Markdown
Owner

Reviewed and merging. Main had already taken parts of this work (the GPU-written tracking and a narrower clwb patch that only runs under Rosetta), so I merged main in and kept main's versions of those. What remains is all opt-in: VICTORY_NO_HANG_WATCHDOG (known 1.0.2.1 build only, patches only where the original bytes match), VICTORY_DSTORAGE_WORKERS, VICTORY_EVICT_HEAP_UAV, VICTORY_SPILL_SHADERS and VICTORY_READ_STATS. I fitted shader spilling to main's new Shader layout and its mesh/pixel linking, which reads the container after translation, and the container is read back from disk before it is translated. I also fixed one clippy lint in read_stats.rs. Windows-target clippy (with and without all features), native tests and cargo xtask policy pass, and CI is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Host GPU runtime: resources, copies, presenting area:title The game's own startup and runtime behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants