perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.8 GB less) #416

Merged
HumanBean merged 8 commits from tonesi/Longshot:perf/388-pcache-low-ram into main 2026-11-16 22:28:50 +00:00
Contributor

Type: perf · Risk: medium · Tested on: Linux, RTX 3070 Ti · Needs: Linux, NVIDIA, 16 GB of RAM (a long played session)

Why

On a 16 GB Linux PC the game's memory outgrows RAM and swap fills as areas change
(#388). About 0.8 GB of it is the pipeline cache's file: it is read
whole at every start and the driver keeps its copy in the game's private memory for the session, although NVIDIA's own
shader cache already holds the same pipelines. Not reading it there takes that off the game's footprint on such a PC.

What changed

On Linux with NVIDIA's own driver, 20 GB of RAM or less and programs loaded at their create calls, the start no longer reads
cache/longshot_vk_pipelines.bin when NVIDIA's own shader cache is on and holds 512 MB or more; everywhere else it is read
as before. With the file not read, nothing is written over it, and play's pipelines are still let go at each save.

  • pipeline cache: pcache_load_off() in gpu/vk/vk_draw.cpp decides through gpu/vk/pcache_load.h (new, no Vulkan in it).
    Where RX_VK_PCACHE_LOAD is unset, the file is not read only when all of these hold:

    • programs are loaded at their create calls (programs_load_at_create());
    • Linux with NVIDIA's own driver (dev.driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY: not NVK);
    • 20 GB of RAM or less (total RAM, sysconf; unknown reads the file);
    • NVIDIA's own shader cache is on and its folder holds 512 MB or more (pcache_load::nvidia_cache()): the folder NVIDIA's
      driver uses, as its README gives it: __GL_SHADER_DISK_CACHE_PATH's GLCache, else $XDG_CACHE_HOME/nvidia/GLCache or
      ~/.cache/nvidia/GLCache, or the earlier drivers' .nv/GLCache where it is there. Only that folder counts, not Mesa's.
      __GL_SHADER_DISK_CACHE=0, no folder for it, a folder that can't be walked through, or under 512 MB: the file is read;
    • not a --prepare-shaders run.

    One log line gives the decision and its reason on every PC (vk: pipeline cache file read: ... or not read: ...), with
    the RAM and NVIDIA's folder and size where they were looked at.

  • pipeline cache: with the file not read (this rule or RX_VK_PCACHE_LOAD=0):

    • play_files_merge() no longer merges the play files into the empty cache, nor writes that cache over the file at 16 of
      them (a session measured on main wrote 38 MB over a 1.2 GB file);
    • pipeline_cache_save() skips only the cache's own part (never fetched nor written) and still calls play_cache_save(),
      which lets play's generation go at each save, the ordinary one every 300 presents included, writing nothing. Before the
      review it returned at once, so play's pipelines stayed in one generation until the close. The log says
      play's generation <n> let go, not written for the first four and every 16th.
    • pcache_drop_stale() drops the files another translator made whether or not the file is read (before, with the file
      unread, 1.2 GB of dead files stayed on disk after every update that changed the translator; RX_VK_PCACHE_STAMP=0
      still keeps them).
  • tests: tests/test_pcache_load.py (new): the rule's table, and pcache_load_off() itself cut out of vk_draw.cpp and run
    against real folders (sparse files): an empty NVIDIA folder beside a full Mesa folder reads the file, the
    path/XDG/HOME/.nv choice, a cache off, missing, not a folder or not readable, NVK, more RAM, start mode, a preparation,
    and the switch over a preparation. tests/test_pipeline_play_cache.py gains no-save (the play files left alone) and
    no-save-periodic (the real pipeline_cache_save(false) into the real play caches: the generation freed past the
    threshold, new work in the next one, no file written); both fail on main. tests/test_pipeline_cache_save.py gains
    no-save. tests/test_pcache_stamp.py checks the stale files go with the file unread.

  • docs: the RX_VK_PCACHE_LOAD row in docs/development.md's GPU switches.

Measurements

Verdict: it helps and passed. On the 16 GB PC the game's private memory + swap at the end of the tour is 0.78-0.82 GB lower (medians on both bases; every PR run below every main run), its peak (resident + swapped) 0.45-0.82 GB lower and swap's peak 1.1-1.4 GB lower; fps and frames over 100 ms are the same. The cost is on the load workers: a program loaded at create takes 5.0-5.1 ms instead of 1.9-2.0 (median), and draws waited for a load 6-7 times a tour instead of 1-4 (195-226 ms in all). No listed pipeline was left in no cache. Lowest MemAvailable is higher too (+80 and +219 MB) but varies a lot from run to run: an observation, not a claim that the pressure is solved.

Hardware: Pop!_OS 24.04 (COSMIC), kernel 7.2.15; NVIDIA GeForce RTX 3070 Ti 8 GB (also drives the desktop), driver 595.104.02;
Intel Core i7-12700K; 16 GB RAM (15,757 MB usable), swap 15.4 GB zram + 4 GB partition
Scene: issue 388's teleport tour from a child save at Zora's River: Zora's Domain, Hyrule Field, Kakariko, the Market, Kokiri
Forest, Lake Hylia, Death Mountain Trail, Goron City, 40 s each with a scripted walk and camera turns (about 7 minutes).
Windowless (headless renderer), Quality preset Auto (this PC: tier 3 here, the reporter's memory_budget=3), output
2560x1440, no DLSS (a source build without it), programs loaded at create (the default with mesh shaders)
Method: two series. First, main 414f56e2 built in full into its own game folder and prepared; the PR's folder is a copy of it after that (caches,
NVIDIA's cache, options; romfs hard-linked) with the PR's longshot_vk.so swapped in, built with RX_VK_ONLY=1 RX_RELEASE=1 nx2/build.py --standalone and the committed renderer profile (RX_VK_PGO, as make_game.py passes it: built so from main
the same way, the .so is byte for byte the full build's). The PR changes the renderer alone and none of the shader stamp's
files, so an update keeps these caches. Three interleaved runs a side (main, PR, main, PR, main, PR), each after RAM had
settled to 9 GB+ available. Then main moved on to 82886e89 (the render thread, on by default here): main's folder was updated in place by a build of 82886e89 and the PR's folder made from it again with the rebased branch's renderer (f0963cdc), and three more pairs ran; the first is a warm-up (main 82886e89's translator stamp changed with sizeof(Program), b2911d33, so each folder's first start prepared every shader again: the PR's in its tour, 14.6 GB peak), the other two compare. main ce9d49b4, the base now, changes only scripts/longshot_ctl.py's Windows console flag. The game's memory every 2 s from /proc/<pid>/status and /proc/<pid>/smaps_rollup (resident +
swapped, file pages left out), the system's from /proc/meminfo; loads and waits from the log's close census; fps from the
renderer's frame log from 60 s on, an observation on the desktop's card, not a timing run
How to reproduce: on a 16 GB Linux PC with NVIDIA and a prepared folder, the same tour (scripts/longshot_ctl.py teleport),
with and without RX_VK_PCACHE_LOAD=1; compare the game's RssAnon + RssShmem + smaps Swap and MemAvailable

Before: main @ 82886e89 (2 runs) After: this PR @ f0963cdc (2 runs) Δ Before: main @ 414f56e2 (3 runs) After: this PR @ 9ea38a42 (3 runs) Δ
peak game total (resident + swapped) 12,638 MB 11,822 MB -816 MB 12,481 MB 12,029 MB -452 MB
game total at the end 12,256 MB 11,576 MB -680 MB 12,122 MB 11,675 MB -447 MB
the game's private memory + its swap at the end 5,133 MB 4,318 MB -816 MB 5,119 MB 4,344 MB -775 MB
peak private memory resident 3,715 MB 3,298 MB -416 MB 3,804 MB 3,384 MB -420 MB
guest window peak (resident + swapped) 7,499 MB 7,492 MB -7 MB 7,477 MB 7,598 MB +121 MB
lowest MemAvailable 566 MB 645 MB +80 MB 367 MB 586 MB +219 MB
system swap in use, peak 6,794 MB 5,428 MB -1,366 MB 6,701 MB 5,627 MB -1,074 MB
fps from 60 s (observation) 53.9 55.0 +1.1 54.3 54.6 +0.3
frames over 100 ms from 60 s 27 25 -2 28 27 -1
program loads at create, median (load workers) 2.0 ms 5.1 ms +3.1 ms 1.9 ms 5.0 ms +3.1 ms
first uses that waited for a load 4 7 +3 1 6 +5
their wait in all 62 ms 226 ms +164 ms 70 ms 195 ms +125 ms
listed pipelines in no cache 0 0 0 0 0 0

Medians; each run, main 82886e89 / this PR f0963cdc (the comparable pairs q2, q3):

main q2-a main q3-a PR q2-c PR q3-c
peak game total, MB 12,658 12,619 11,842 11,803
game total at the end, MB 12,194 12,317 11,614 11,537
private memory + swap at the end, MB 5,174 5,092 4,318 4,317
lowest MemAvailable, MB 489 642 655 635
system swap peak, MB 6,935 6,652 5,533 5,322
fps / frames over 100 ms 54.2 / 27 53.6 / 27 55.7 / 21 54.3 / 29
program loads at create, median ms 2.0 2.0 5.1 5.1
first uses that waited / their wait, ms 3 / 59 5 / 64 10 / 229 4 / 223

Each run, main 414f56e2 / this PR 9ea38a42:

main p1-a main p2-a main p3-a PR p1-c PR p2-c PR p3-c
peak game total, MB 12,481 12,389 12,695 12,095 11,826 12,029
game total at the end, MB 12,073 12,122 12,384 11,718 11,652 11,675
private memory + swap at the end, MB 5,094 5,119 5,193 4,415 4,344 4,332
lowest MemAvailable, MB 367 210 406 521 586 722
system swap peak, MB 6,243 6,701 6,862 5,479 5,856 5,627
fps / frames over 100 ms 53.7 / 27 54.3 / 28 54.4 / 31 52.0 / 27 54.6 / 26 54.6 / 30
program loads at create, median ms 1.59 1.87 1.89 4.97 4.94 5.04
first uses that waited / their wait, ms 1 / 31 0 / 70 1 / 108 6 / 195 9 / 223 6 / 193

The PR's folder kept its 1.2 GB longshot_vk_pipelines.bin and the play files it was handed through all its tours, none
written, merged or folded; main's wrote 5-13 play files a tour and folded 22 into its file at one start. Every run reached
all eight areas, with no device lost and no kernel or NVRM line. Measured commits fetchable from the fork:
measured/416-9ea38a42, measured/416-f0963cdc (and the first measurement's measured/416-999bc37f) on
https://git.magicbean.dev/tonesi/Longshot.

this PR (q2-c), the decision: vk: pipeline cache file not read: 20 GB of RAM or less, programs loaded at create: NVIDIA's own shader cache answers them (15757 MB of RAM, NVIDIA's own shader cache 1200 MB in <game folder>/.nv-cache/GLCache; RX_VK_PCACHE_LOAD=1 reads it)
this PR:  vk: pipeline cache <game folder>/cache/longshot_vk_pipelines.bin (0 KB)
main:     vk: pipeline cache <game folder>/cache/longshot_vk_pipelines.bin (1199252 KB)
this PR:  vk: pipeline cache: play's generation 2 let go, not written (the file not read): 21 pipelines, 9 from the driver's cache, 12 compiled
main (p3-a):    vk: program loads at create (close): 7437 queued, 7437 loaded (median 1.89 ms, 99th percentile 16.32 ms, worst 125.22 ms, 22866 ms and 1398.3 MB read in all); ... a first use ran 23 itself and waited for 1 (107.6 ms)
this PR (p3-c): vk: program loads at create (close): 7435 queued, 7435 loaded (median 5.04 ms, 99th percentile 28.68 ms, worst 98.17 ms, 49832 ms and 1398.7 MB read in all); ... a first use ran 30 itself and waited for 6 (192.6 ms)
guard, __GL_SHADER_DISK_CACHE=0: vk: pipeline cache file read: NVIDIA's own shader cache is off (15757 MB of RAM, NVIDIA's own shader cache off (__GL_SHADER_DISK_CACHE, or no folder for it))
guard, the review's case:  vk: driver shader cache at the start: 600 MB (<report>/guard-nv/GLCache 0 MB, <report>/guard-mesa 600 MB)
                           vk: pipeline cache file read: NVIDIA's own shader cache is nearly empty (15757 MB of RAM, NVIDIA's own shader cache 0 MB in <report>/guard-nv/GLCache)
another translator's files, the head's renderer on the PR's folder after main's update: vk: pipeline cache: 14 files made for another translator dropped (1219 MB); it starts empty

The first measurement (main 0caf0618 against 999bc37f, before the review's fixes, three runs a side on the same PC and tour)
gave -831 MB peak, -733 MB private + swap at the end, +329 MB lowest MemAvailable; its runs are in docs/tested/ too.

Flags and settings

RX_VK_PCACHE_LOAD gets an automatic default where it is unset; LONGSHOT_PREPARE_ONLY is now read by the rule too.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_PCACHE_LOAD=0 or 1 The pipeline cache file not read, not saved and its play files left alone (0), or read as before (1); either way whatever the rule says, a --prepare-shaders run included Unset: read everywhere Unset: not read on Linux + NVIDIA's own driver + 20 GB of RAM or less + programs loaded at create + NVIDIA's own cache on and 512 MB or more; read everywhere else About 0.7-0.8 GB less of the game in RAM and swap on a 16 GB PC; program loads at create a few ms slower on the load workers Helps: 16 GB Linux PCs with NVIDIA. Doesn't help: programs loaded before the title (no saving measured, a precompile twice as long), PCs with more RAM, Windows. Untested: Linux NVIDIA with 8 or 12 GB of RAM This default. 1 reads it on the small PC, for an A/B
LONGSHOT_PREPARE_ONLY The internal flag --prepare-shaders sets for its own process Set only by --prepare-shaders Unchanged; now also read by pcache_load_off(), so a preparation reads and saves the file - - As it is

Testing

Tested:

  • In the game on the PC above, windowless, the tour under Measurements: three interleaved runs a side on main 414f56e2
    (the PR at 9ea38a42), then three on main 82886e89 (the PR at f0963cdc; the first pair a warm-up). Every run reached all
    eight areas, with no device lost and 0 kernel or NVRM lines.
  • The decision line in every PR run (not read, NVIDIA's cache 1.2 GB), and the play's generation <n> let go lines as
    play went on (the ordinary save letting play's pipelines go: review point 1).
  • The guard in the game, on the PR's folder, short starts: __GL_SHADER_DISK_CACHE=0 reads the file; a fresh, empty
    __GL_SHADER_DISK_CACHE_PATH beside a Mesa folder of 600 MB (MESA_SHADER_CACHE_DIR, a sparse file) reads the file:
    the start's own driver-cache line shows 600 MB in all, which the guard before the review summed past 512 MB (review
    point 2).
  • An update in the game: main 414f56e2 → 82886e89 changed the translator stamp. The PR's folder prepared every shader again
    at its first start, with the file not read, and loaded at create from then on with 0 listed pipelines in no cache. The
    head's stale-file fix then dropped the 14 files of the old translator (1219 MB) at a start, still not reading the file.
    That short start (4 minutes, idle at the title) logged four NVRM lines 3 s before its timeout ended it
    (dmaAllocMapping_GM107: can't alloc VA space for mapping, NV_ERR_NO_MEMORY from the mapping reuse callback), with no
    device lost and nothing in the game's log; none of the other 21 game runs today, main's or the PR's, logged any. Not
    understood yet.
  • Game-free: tests/test_pcache_load.py (the table, and pcache_load_off() against real folders: 20 cases),
    tests/test_pipeline_play_cache.py (14 cases; no-save and no-save-periodic fail on main, no-save-periodic on the
    branch before the review at line 493, the retirement), tests/test_pipeline_cache_save.py (no-save) and
    tests/test_pcache_stamp.py, with GCC and Clang.
  • The whole suite on da116f0e's code (52580a68 before the last rebase; Linux, python -I -B tests/run_all.py --jobs 8):
    538 passed, 10 failed, 30 skipped. main 82886e89 the same way: 537 passed and the same 10 failed:
    test_appimage_player_build, test_cpm_discovery, test_env_on (main's RX_VK_PRESENT_AFTER_SIGNAL),
    test_lift_cleanup_error, test_linux_preflight, test_make_game_cache, test_readback_late, test_vram_budget_row,
    test_walk_key (no hos_oot_autoload_input stub), and test_crash_record (passes alone on both: slow under the suite's
    load).
  • The Windows back end (longshot_vk.dll) of the head compiled and linked on this PC as CI's build-windows.yml builds it,
    with the pinned llvm-mingw 20261104 (RX_TARGET=windows RX_VK_ONLY=1 RX_RELEASE=1 nx2/build.py --standalone): 0 failed.
    The three changed test programs compiled for Windows (the workbench's fixture syntax check, and the adapter test linked
    with llvm-mingw), not run there.

Not tested:

  • Windows in the game: the rule's Windows branch reads the file, as main does. The Windows back end was compiled, not run.
  • Linux with 8 or 12 GB of RAM, other NVIDIA cards and drivers, and a driver update with a cache of the old driver still
    there: a start on a new driver finds the driver's part of the shaders made for another driver (warmed_stamp holds
    driverVersion) and makes it again before play (prepare_run), from the source, not run here.
  • NVK, AMD and Intel on Linux: not switched by this PR (p0lux's Steam Deck numbers in the comments: 200-300 MiB less without
    the file on RADV, arrivals a little rougher on 4 cores; a Mesa rule would read the folder MESA_SHADER_CACHE_DIR names).
  • A session hours long. The tours were 7 minutes.

Must be tested:

  • Linux, NVIDIA (any RTX), 16 GB of RAM: play 20+ minutes across several areas on this PR's build, programs loaded at create
    (the default with mesh shaders), then the same with RX_VK_PCACHE_LOAD=1; expecting the log's pipeline cache file not read line, play's generation ... let go lines as play goes on, no listed pipelines ... in no cache at the close, and
    play no rougher than with RX_VK_PCACHE_LOAD=1 (by hand: test request T-XTVW, waiting for the testing wanted label; free -m during play both ways)

Risks

What could break: on the PCs the rule covers, a program loaded at create takes its pipelines from NVIDIA's disk cache
instead of the file's in-memory copy: each load is slower on the load workers and draws wait for a load a little more often
(the table). If NVIDIA's cache holds 512 MB or more that doesn't answer this game (another program's shaders, or an old
driver's), pipelines the file would have answered are compiled when first needed; more than 500 listed misses write
longshot_load_start.txt, and the next start loads programs before the title, where the rule reads the file again.

Turning it off: RX_VK_PCACHE_LOAD=1 reads the file again; reverting the commit is enough.

Compatibility: nothing to redo after updating: the shader stamp's files are untouched, so the program cache and the
pipeline cache files stay. Where the file isn't read it and its play files stay on disk as they were, for a start that reads
it (they are neither updated nor written over), unless another translator made them: those go at the start, as where it is
read. The first start after an update that changes the translator prepares as on main, and on these PCs keeps what it builds
in NVIDIA's own cache, not in the file. No MKWVK_API_VERSION change, no options or save change.

Issues

See #388
See #223
See #415
See https://github.com/NotRexed/Hookshot/pull/2206

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.

🤖 Generated with Claude Code

**Type:** perf · **Risk:** medium · **Tested on:** Linux, RTX 3070 Ti · **Needs:** Linux, NVIDIA, 16 GB of RAM (a long played session) ## Why On a 16 GB Linux PC the game's memory outgrows RAM and swap fills as areas change (https://git.magicbean.dev/MagicBeanDev/Longshot/issues/388). About 0.8 GB of it is the pipeline cache's file: it is read whole at every start and the driver keeps its copy in the game's private memory for the session, although NVIDIA's own shader cache already holds the same pipelines. Not reading it there takes that off the game's footprint on such a PC. ## What changed On Linux with NVIDIA's own driver, 20 GB of RAM or less and programs loaded at their create calls, the start no longer reads `cache/longshot_vk_pipelines.bin` when NVIDIA's own shader cache is on and holds 512 MB or more; everywhere else it is read as before. With the file not read, nothing is written over it, and play's pipelines are still let go at each save. - pipeline cache: `pcache_load_off()` in `gpu/vk/vk_draw.cpp` decides through `gpu/vk/pcache_load.h` (new, no Vulkan in it). Where `RX_VK_PCACHE_LOAD` is unset, the file is not read only when all of these hold: - programs are loaded at their create calls (`programs_load_at_create()`); - Linux with NVIDIA's own driver (`dev.driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY`: not NVK); - 20 GB of RAM or less (total RAM, `sysconf`; unknown reads the file); - NVIDIA's own shader cache is on and its folder holds 512 MB or more (`pcache_load::nvidia_cache()`): the folder NVIDIA's driver uses, as its README gives it: `__GL_SHADER_DISK_CACHE_PATH`'s `GLCache`, else `$XDG_CACHE_HOME/nvidia/GLCache` or `~/.cache/nvidia/GLCache`, or the earlier drivers' `.nv/GLCache` where it is there. Only that folder counts, not Mesa's. `__GL_SHADER_DISK_CACHE=0`, no folder for it, a folder that can't be walked through, or under 512 MB: the file is read; - not a `--prepare-shaders` run. One log line gives the decision and its reason on every PC (`vk: pipeline cache file read: ...` or `not read: ...`), with the RAM and NVIDIA's folder and size where they were looked at. - pipeline cache: with the file not read (this rule or `RX_VK_PCACHE_LOAD=0`): - `play_files_merge()` no longer merges the play files into the empty cache, nor writes that cache over the file at 16 of them (a session measured on main wrote 38 MB over a 1.2 GB file); - `pipeline_cache_save()` skips only the cache's own part (never fetched nor written) and still calls `play_cache_save()`, which lets play's generation go at each save, the ordinary one every 300 presents included, writing nothing. Before the review it returned at once, so play's pipelines stayed in one generation until the close. The log says `play's generation <n> let go, not written` for the first four and every 16th. - `pcache_drop_stale()` drops the files another translator made whether or not the file is read (before, with the file unread, 1.2 GB of dead files stayed on disk after every update that changed the translator; `RX_VK_PCACHE_STAMP=0` still keeps them). - tests: `tests/test_pcache_load.py` (new): the rule's table, and `pcache_load_off()` itself cut out of `vk_draw.cpp` and run against real folders (sparse files): an empty NVIDIA folder beside a full Mesa folder reads the file, the path/XDG/HOME/`.nv` choice, a cache off, missing, not a folder or not readable, NVK, more RAM, start mode, a preparation, and the switch over a preparation. `tests/test_pipeline_play_cache.py` gains `no-save` (the play files left alone) and `no-save-periodic` (the real `pipeline_cache_save(false)` into the real play caches: the generation freed past the threshold, new work in the next one, no file written); both fail on `main`. `tests/test_pipeline_cache_save.py` gains `no-save`. `tests/test_pcache_stamp.py` checks the stale files go with the file unread. - docs: the `RX_VK_PCACHE_LOAD` row in `docs/development.md`'s GPU switches. ## Measurements **Verdict:** it helps and passed. On the 16 GB PC the game's private memory + swap at the end of the tour is 0.78-0.82 GB lower (medians on both bases; every PR run below every main run), its peak (resident + swapped) 0.45-0.82 GB lower and swap's peak 1.1-1.4 GB lower; fps and frames over 100 ms are the same. The cost is on the load workers: a program loaded at create takes 5.0-5.1 ms instead of 1.9-2.0 (median), and draws waited for a load 6-7 times a tour instead of 1-4 (195-226 ms in all). No listed pipeline was left in no cache. Lowest MemAvailable is higher too (+80 and +219 MB) but varies a lot from run to run: an observation, not a claim that the pressure is solved. Hardware: Pop!_OS 24.04 (COSMIC), kernel 7.2.15; NVIDIA GeForce RTX 3070 Ti 8 GB (also drives the desktop), driver 595.104.02; Intel Core i7-12700K; 16 GB RAM (15,757 MB usable), swap 15.4 GB zram + 4 GB partition Scene: issue 388's teleport tour from a child save at Zora's River: Zora's Domain, Hyrule Field, Kakariko, the Market, Kokiri Forest, Lake Hylia, Death Mountain Trail, Goron City, 40 s each with a scripted walk and camera turns (about 7 minutes). Windowless (headless renderer), Quality preset Auto (this PC: tier 3 here, the reporter's `memory_budget=3`), output 2560x1440, no DLSS (a source build without it), programs loaded at create (the default with mesh shaders) Method: two series. First, main 414f56e2 built in full into its own game folder and prepared; the PR's folder is a copy of it after that (caches, NVIDIA's cache, options; romfs hard-linked) with the PR's `longshot_vk.so` swapped in, built with `RX_VK_ONLY=1 RX_RELEASE=1 nx2/build.py --standalone` and the committed renderer profile (`RX_VK_PGO`, as `make_game.py` passes it: built so from main the same way, the `.so` is byte for byte the full build's). The PR changes the renderer alone and none of the shader stamp's files, so an update keeps these caches. Three interleaved runs a side (main, PR, main, PR, main, PR), each after RAM had settled to 9 GB+ available. Then main moved on to 82886e89 (the render thread, on by default here): main's folder was updated in place by a build of 82886e89 and the PR's folder made from it again with the rebased branch's renderer (f0963cdc), and three more pairs ran; the first is a warm-up (main 82886e89's translator stamp changed with `sizeof(Program)`, b2911d33, so each folder's first start prepared every shader again: the PR's in its tour, 14.6 GB peak), the other two compare. main ce9d49b4, the base now, changes only `scripts/longshot_ctl.py`'s Windows console flag. The game's memory every 2 s from `/proc/<pid>/status` and `/proc/<pid>/smaps_rollup` (resident + swapped, file pages left out), the system's from `/proc/meminfo`; loads and waits from the log's close census; fps from the renderer's frame log from 60 s on, an observation on the desktop's card, not a timing run How to reproduce: on a 16 GB Linux PC with NVIDIA and a prepared folder, the same tour (`scripts/longshot_ctl.py teleport`), with and without `RX_VK_PCACHE_LOAD=1`; compare the game's `RssAnon + RssShmem + smaps Swap` and `MemAvailable` | | Before: main @ 82886e89 (2 runs) | After: this PR @ f0963cdc (2 runs) | Δ | Before: main @ 414f56e2 (3 runs) | After: this PR @ 9ea38a42 (3 runs) | Δ | |---|---:|---:|---:|---:|---:|---:| | peak game total (resident + swapped) | 12,638 MB | **11,822 MB** | -816 MB | 12,481 MB | **12,029 MB** | -452 MB | | game total at the end | 12,256 MB | **11,576 MB** | -680 MB | 12,122 MB | **11,675 MB** | -447 MB | | the game's private memory + its swap at the end | 5,133 MB | **4,318 MB** | -816 MB | 5,119 MB | **4,344 MB** | -775 MB | | peak private memory resident | 3,715 MB | 3,298 MB | -416 MB | 3,804 MB | 3,384 MB | -420 MB | | guest window peak (resident + swapped) | 7,499 MB | 7,492 MB | -7 MB | 7,477 MB | 7,598 MB | +121 MB | | lowest MemAvailable | 566 MB | 645 MB | +80 MB | 367 MB | 586 MB | +219 MB | | system swap in use, peak | 6,794 MB | **5,428 MB** | -1,366 MB | 6,701 MB | **5,627 MB** | -1,074 MB | | fps from 60 s (observation) | 53.9 | 55.0 | +1.1 | 54.3 | 54.6 | +0.3 | | frames over 100 ms from 60 s | 27 | 25 | -2 | 28 | 27 | -1 | | program loads at create, median (load workers) | 2.0 ms | 5.1 ms | +3.1 ms | 1.9 ms | 5.0 ms | +3.1 ms | | first uses that waited for a load | 4 | 7 | +3 | 1 | 6 | +5 | | their wait in all | 62 ms | 226 ms | +164 ms | 70 ms | 195 ms | +125 ms | | listed pipelines in no cache | 0 | 0 | 0 | 0 | 0 | 0 | Medians; each run, main 82886e89 / this PR f0963cdc (the comparable pairs q2, q3): | | main q2-a | main q3-a | PR q2-c | PR q3-c | |---|---:|---:|---:|---:| | peak game total, MB | 12,658 | 12,619 | 11,842 | 11,803 | | game total at the end, MB | 12,194 | 12,317 | 11,614 | 11,537 | | private memory + swap at the end, MB | 5,174 | 5,092 | 4,318 | 4,317 | | lowest MemAvailable, MB | 489 | 642 | 655 | 635 | | system swap peak, MB | 6,935 | 6,652 | 5,533 | 5,322 | | fps / frames over 100 ms | 54.2 / 27 | 53.6 / 27 | 55.7 / 21 | 54.3 / 29 | | program loads at create, median ms | 2.0 | 2.0 | 5.1 | 5.1 | | first uses that waited / their wait, ms | 3 / 59 | 5 / 64 | 10 / 229 | 4 / 223 | Each run, main 414f56e2 / this PR 9ea38a42: | | main p1-a | main p2-a | main p3-a | PR p1-c | PR p2-c | PR p3-c | |---|---:|---:|---:|---:|---:|---:| | peak game total, MB | 12,481 | 12,389 | 12,695 | 12,095 | 11,826 | 12,029 | | game total at the end, MB | 12,073 | 12,122 | 12,384 | 11,718 | 11,652 | 11,675 | | private memory + swap at the end, MB | 5,094 | 5,119 | 5,193 | 4,415 | 4,344 | 4,332 | | lowest MemAvailable, MB | 367 | 210 | 406 | 521 | 586 | 722 | | system swap peak, MB | 6,243 | 6,701 | 6,862 | 5,479 | 5,856 | 5,627 | | fps / frames over 100 ms | 53.7 / 27 | 54.3 / 28 | 54.4 / 31 | 52.0 / 27 | 54.6 / 26 | 54.6 / 30 | | program loads at create, median ms | 1.59 | 1.87 | 1.89 | 4.97 | 4.94 | 5.04 | | first uses that waited / their wait, ms | 1 / 31 | 0 / 70 | 1 / 108 | 6 / 195 | 9 / 223 | 6 / 193 | The PR's folder kept its 1.2 GB `longshot_vk_pipelines.bin` and the play files it was handed through all its tours, none written, merged or folded; main's wrote 5-13 play files a tour and folded 22 into its file at one start. Every run reached all eight areas, with no device lost and no kernel or NVRM line. Measured commits fetchable from the fork: `measured/416-9ea38a42`, `measured/416-f0963cdc` (and the first measurement's `measured/416-999bc37f`) on https://git.magicbean.dev/tonesi/Longshot. ``` this PR (q2-c), the decision: vk: pipeline cache file not read: 20 GB of RAM or less, programs loaded at create: NVIDIA's own shader cache answers them (15757 MB of RAM, NVIDIA's own shader cache 1200 MB in <game folder>/.nv-cache/GLCache; RX_VK_PCACHE_LOAD=1 reads it) this PR: vk: pipeline cache <game folder>/cache/longshot_vk_pipelines.bin (0 KB) main: vk: pipeline cache <game folder>/cache/longshot_vk_pipelines.bin (1199252 KB) this PR: vk: pipeline cache: play's generation 2 let go, not written (the file not read): 21 pipelines, 9 from the driver's cache, 12 compiled main (p3-a): vk: program loads at create (close): 7437 queued, 7437 loaded (median 1.89 ms, 99th percentile 16.32 ms, worst 125.22 ms, 22866 ms and 1398.3 MB read in all); ... a first use ran 23 itself and waited for 1 (107.6 ms) this PR (p3-c): vk: program loads at create (close): 7435 queued, 7435 loaded (median 5.04 ms, 99th percentile 28.68 ms, worst 98.17 ms, 49832 ms and 1398.7 MB read in all); ... a first use ran 30 itself and waited for 6 (192.6 ms) guard, __GL_SHADER_DISK_CACHE=0: vk: pipeline cache file read: NVIDIA's own shader cache is off (15757 MB of RAM, NVIDIA's own shader cache off (__GL_SHADER_DISK_CACHE, or no folder for it)) guard, the review's case: vk: driver shader cache at the start: 600 MB (<report>/guard-nv/GLCache 0 MB, <report>/guard-mesa 600 MB) vk: pipeline cache file read: NVIDIA's own shader cache is nearly empty (15757 MB of RAM, NVIDIA's own shader cache 0 MB in <report>/guard-nv/GLCache) another translator's files, the head's renderer on the PR's folder after main's update: vk: pipeline cache: 14 files made for another translator dropped (1219 MB); it starts empty ``` The first measurement (main 0caf0618 against 999bc37f, before the review's fixes, three runs a side on the same PC and tour) gave -831 MB peak, -733 MB private + swap at the end, +329 MB lowest MemAvailable; its runs are in `docs/tested/` too. ### Flags and settings `RX_VK_PCACHE_LOAD` gets an automatic default where it is unset; `LONGSHOT_PREPARE_ONLY` is now read by the rule too. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_PCACHE_LOAD=0` or `1` | The pipeline cache file not read, not saved and its play files left alone (`0`), or read as before (`1`); either way whatever the rule says, a `--prepare-shaders` run included | Unset: read everywhere | Unset: not read on Linux + NVIDIA's own driver + 20 GB of RAM or less + programs loaded at create + NVIDIA's own cache on and 512 MB or more; read everywhere else | About 0.7-0.8 GB less of the game in RAM and swap on a 16 GB PC; program loads at create a few ms slower on the load workers | Helps: 16 GB Linux PCs with NVIDIA. Doesn't help: programs loaded before the title (no saving measured, a precompile twice as long), PCs with more RAM, Windows. Untested: Linux NVIDIA with 8 or 12 GB of RAM | This default. `1` reads it on the small PC, for an A/B | | `LONGSHOT_PREPARE_ONLY` | The internal flag `--prepare-shaders` sets for its own process | Set only by `--prepare-shaders` | Unchanged; now also read by `pcache_load_off()`, so a preparation reads and saves the file | - | - | As it is | ## Testing **Tested:** - In the game on the PC above, windowless, the tour under Measurements: three interleaved runs a side on main 414f56e2 (the PR at 9ea38a42), then three on main 82886e89 (the PR at f0963cdc; the first pair a warm-up). Every run reached all eight areas, with no device lost and 0 kernel or NVRM lines. - The decision line in every PR run (`not read`, NVIDIA's cache 1.2 GB), and the `play's generation <n> let go` lines as play went on (the ordinary save letting play's pipelines go: review point 1). - The guard in the game, on the PR's folder, short starts: `__GL_SHADER_DISK_CACHE=0` reads the file; a fresh, empty `__GL_SHADER_DISK_CACHE_PATH` beside a Mesa folder of 600 MB (`MESA_SHADER_CACHE_DIR`, a sparse file) reads the file: the start's own driver-cache line shows 600 MB in all, which the guard before the review summed past 512 MB (review point 2). - An update in the game: main 414f56e2 → 82886e89 changed the translator stamp. The PR's folder prepared every shader again at its first start, with the file not read, and loaded at create from then on with 0 listed pipelines in no cache. The head's stale-file fix then dropped the 14 files of the old translator (1219 MB) at a start, still not reading the file. That short start (4 minutes, idle at the title) logged four NVRM lines 3 s before its timeout ended it (`dmaAllocMapping_GM107: can't alloc VA space for mapping`, `NV_ERR_NO_MEMORY` from the mapping reuse callback), with no device lost and nothing in the game's log; none of the other 21 game runs today, main's or the PR's, logged any. Not understood yet. - Game-free: `tests/test_pcache_load.py` (the table, and `pcache_load_off()` against real folders: 20 cases), `tests/test_pipeline_play_cache.py` (14 cases; `no-save` and `no-save-periodic` fail on main, `no-save-periodic` on the branch before the review at line 493, the retirement), `tests/test_pipeline_cache_save.py` (`no-save`) and `tests/test_pcache_stamp.py`, with GCC and Clang. - The whole suite on da116f0e's code (52580a68 before the last rebase; Linux, `python -I -B tests/run_all.py --jobs 8`): 538 passed, 10 failed, 30 skipped. main 82886e89 the same way: 537 passed and the same 10 failed: `test_appimage_player_build`, `test_cpm_discovery`, `test_env_on` (main's `RX_VK_PRESENT_AFTER_SIGNAL`), `test_lift_cleanup_error`, `test_linux_preflight`, `test_make_game_cache`, `test_readback_late`, `test_vram_budget_row`, `test_walk_key` (no `hos_oot_autoload_input` stub), and `test_crash_record` (passes alone on both: slow under the suite's load). - The Windows back end (`longshot_vk.dll`) of the head compiled and linked on this PC as CI's build-windows.yml builds it, with the pinned llvm-mingw 20261104 (`RX_TARGET=windows RX_VK_ONLY=1 RX_RELEASE=1 nx2/build.py --standalone`): 0 failed. The three changed test programs compiled for Windows (the workbench's fixture syntax check, and the adapter test linked with llvm-mingw), not run there. **Not tested:** - Windows in the game: the rule's Windows branch reads the file, as main does. The Windows back end was compiled, not run. - Linux with 8 or 12 GB of RAM, other NVIDIA cards and drivers, and a driver update with a cache of the old driver still there: a start on a new driver finds the driver's part of the shaders made for another driver (`warmed_stamp` holds `driverVersion`) and makes it again before play (`prepare_run`), from the source, not run here. - NVK, AMD and Intel on Linux: not switched by this PR (p0lux's Steam Deck numbers in the comments: 200-300 MiB less without the file on RADV, arrivals a little rougher on 4 cores; a Mesa rule would read the folder `MESA_SHADER_CACHE_DIR` names). - A session hours long. The tours were 7 minutes. **Must be tested:** - Linux, NVIDIA (any RTX), 16 GB of RAM: play 20+ minutes across several areas on this PR's build, programs loaded at create (the default with mesh shaders), then the same with `RX_VK_PCACHE_LOAD=1`; expecting the log's `pipeline cache file not read` line, `play's generation ... let go` lines as play goes on, no `listed pipelines ... in no cache` at the close, and play no rougher than with `RX_VK_PCACHE_LOAD=1` (by hand: test request T-XTVW, waiting for the `testing wanted` label; `free -m` during play both ways) ## Risks **What could break:** on the PCs the rule covers, a program loaded at create takes its pipelines from NVIDIA's disk cache instead of the file's in-memory copy: each load is slower on the load workers and draws wait for a load a little more often (the table). If NVIDIA's cache holds 512 MB or more that doesn't answer this game (another program's shaders, or an old driver's), pipelines the file would have answered are compiled when first needed; more than 500 listed misses write `longshot_load_start.txt`, and the next start loads programs before the title, where the rule reads the file again. **Turning it off:** `RX_VK_PCACHE_LOAD=1` reads the file again; reverting the commit is enough. **Compatibility:** nothing to redo after updating: the shader stamp's files are untouched, so the program cache and the pipeline cache files stay. Where the file isn't read it and its play files stay on disk as they were, for a start that reads it (they are neither updated nor written over), unless another translator made them: those go at the start, as where it is read. The first start after an update that changes the translator prepares as on main, and on these PCs keeps what it builds in NVIDIA's own cache, not in the file. No `MKWVK_API_VERSION` change, no options or save change. ## Issues See https://git.magicbean.dev/MagicBeanDev/Longshot/issues/388 See https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/223 See https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/415 See https://github.com/NotRexed/Hookshot/pull/2206 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The pipeline cache file (1.2 GB after a preparation) is read whole at every start and the driver keeps its copy in the
process's private memory for the session. On Linux the drivers keep their own shader caches with room for it
(driver_cache_room), and a program loaded at its create call finds its pipelines there too. Where all of these hold the
file is now not read: programs loaded at create, Linux with NVIDIA's driver, 20 GB of RAM or less, the driver's own cache
not nearly empty, not a --prepare-shaders run (gpu/vk/pcache_load.h). RX_VK_PCACHE_LOAD=1 reads it, =0 never.

With the file not read (this or RX_VK_PCACHE_LOAD=0), the start no longer merges the play files into the empty cache and
writes it over the file at 16 of them (a 38 MB cache over a 1.2 GB file), and play's generations are not written.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(tested): issue 388's memory tour, main and this branch, three runs each
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 17s
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
beanstalk/approval approved by HumanBean (reviewed)
Website / Website on Cloudflare (pull_request) Has been cancelled
beanstalk/linux+nvidia 0/1 pass, 0 running, 1 queued
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
4fd82b7559
Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Description completed: the measured commit named on the 'this PR' line (999bc37f, rebased since onto 5e072fc8 unchanged, and why the numbers still hold), LONGSHOT_PREPARE_ONLY in the flags table, the Windows back end compiled and linked with the pinned llvm-mingw (Linux build, as CI does), and test request T-XTVW for a longer session on another 16 GB Linux NVIDIA PC.

Description completed: the measured commit named on the 'this PR' line (999bc37f, rebased since onto 5e072fc8 unchanged, and why the numbers still hold), LONGSHOT_PREPARE_ONLY in the flags table, the Windows back end compiled and linked with the pinned llvm-mingw (Linux build, as CI does), and test request T-XTVW for a longer session on another 16 GB Linux NVIDIA PC.
tonesi changed title from WIP: perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.7-0.8 GB less) to perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.7-0.8 GB less) 2026-11-14 11:53:25 +00:00
mooki left a comment

Read head 4fd82b75 against main 5e072fc8: the complete eight-file diff, description, sole comment, empty reviews, issue 388 and both comments, cache readers/writers, program-load dispatch and the relevant changes in 415 and 370; ran nine game-free check invocations across five files, all passed, with GCC and Clang for the compiled checks. No game, full build or timing run.

What's good

  • The cost is real. Main maps the complete base file and hands it to vkCreatePipelineCache; file-backed input avoids a large temporary byte vector, not the driver's retained cache. The reported memory reduction is consistent with removing that retained input.
  • The explicit-off overwrite fix is separate and useful. The new guard in play_files_merge() prevents an empty base cache plus 16 rolling files from replacing the larger base file. The new no-save case passes with both compilers and preserves the authored base and rolling files.
  • The decision is latched once, keeps an explicit override, and excludes ordinary preparation and load-before-title starts from the automatic skip. It does not change the translated-program format or shader-stamp inputs.

Must change

  1. Reach generation retirement from the ordinary save entry point. In gpu/vk/vk_draw.cpp, lines 945-949, the new no-save branch destroys retired play caches, but the periodic caller cannot reach it: vk_replay.cpp, line 4099, calls pipeline_cache_save(false), whose first condition at vk_draw.cpp, line 10343, returns when pcache_no_save is true. play_cache_begin() still creates a generation, and create_cached() keeps adding play pipelines to it. On the PCs newly selected by this default, those additions therefore stay in the same generation until close, instead of being retired at the periodic saves as on main. Route generation retirement around the file-write prohibition while keeping the current user-count synchronization. Extend the fixture through pipeline_cache_save(false), after enough new pipelines to trigger a save, rather than calling play_cache_save() directly. It should prove that the old cache is destroyed, new work still succeeds, and no file is written. Traced through the source; the passing no-save case does not exercise this caller. No long-session memory run.

  2. Use the selected driver's cache for the cold-cache guard. In gpu/vk/vk_draw.cpp, lines 1055-1057, the new decision treats driver_cache_bytes(nullptr) as NVIDIA's cache size. That helper, lines 9619-9633, adds NVIDIA's and Mesa's folders together. A fresh, empty __GL_SHADER_DISK_CACHE_PATH with at least 512 MiB left in Mesa's folder therefore selects “file not read”, even though NVIDIA's cache is empty. This is not just the disclosed case of other programs filling NVIDIA's cache: an unrelated driver's bytes defeat the explicit cold-cache fallback. The base and rolling files are then ignored, and listed pipelines which neither live cache can answer are deferred to their first draw or dispatch (vk_programs.cpp, lines 240-255). Count only the selected driver's cache for this decision and treat an unavailable scan as unknown/cold. Add an adapter-level case with an empty NVIDIA folder and a populated Mesa folder, requiring the file to be read. Traced through the source, not reproduced in a game; the new table test supplies a number directly and never exercises folder selection.

What the condition actually selects

  • The platform branch is #ifndef _WIN32, and the GPU check is vendorID == 0x10DE. On the supported platforms this means Linux with an NVIDIA GPU, not specifically NVIDIA's proprietary driver. Mesa NVK is not excluded by that check; dev.driver_id is already available if proprietary-driver-only is the intended scope.
  • RAM is sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE), shifted right by 20. It is total RAM reported by the OS, not current free RAM, VRAM or a process memory allowance. Unknown RAM falls back to reading the file. The inclusive limit is 20,480 MiB, or 20 GiB, with the byte count rounded down to MiB. A typical 16 GiB PC qualifies, including the reported 15,757 MiB machine. Typical 24 and 32 GiB PCs do not; unusually large hardware reservations can change the reported total.
  • programs_load_decide() runs after device creation and before this choice. The existing load mode matters: native mesh normally selects create, while the fallback, compressed program cache or an existing load-start marker can select start. This PR does not help the issue's original load-before-title configuration by default.
  • Nonempty RX_VK_PCACHE_LOAD=0, off, false or no forces the skip; 1 or another non-off value forces loading. Empty is treated as automatic. The switch wins over preparation too: choose(0, true, ...) skips the file, and the new test explicitly requires that. The documentation's “always by --prepare-shaders” needs that exception.
  • The reason line is emitted only for small-PC automatic candidates or an explicit override. Other automatic paths, including Windows, larger RAM and load-before-title, do not get that reason line. An explicit override also prints a driver-cache size of 0 without scanning it, so that number is not an observation of an empty cache. The later path/size line remains.

Cold, disabled or unwritable driver caches

A genuinely empty aggregate scan falls back to main's file-loading path. A first start without a valid warm marker also has the existing up-front preparation/warm pass, so it is not correct to say every cold first start necessarily compiles everything in play.

The size check does not establish that this game's entries are present, compatible or usable. It does not check __GL_SHADER_DISK_CACHE=0, and it does not establish usability on a read-only home. Read-only storage alone does not prove existing entries cannot be read. NVIDIA also documents that its cached binaries are driver-version-specific: https://download.nvidia.com/XFree86/Linux-x86_64/570.124.04/README/openglenvvariables.html. These cases need separate evidence, not a directory-size inference.

With an existing warm marker, a skipped file and driver misses, loads at create only probe the caches. Missing pipelines are compiled when first needed in play. More than 500 listed misses can write longshot_load_start.txt, making the next run load before the title and disabling this automatic memory saving. The description discloses unrelated NVIDIA entries, but “this costs nothing beyond main” is not established for disabled caches, read-only storage or other drivers.

Files retained for the next run

When the file is skipped, neither the base file nor new rolling files are written. Existing published files and their stamp are left alone; old temporary-file cleanup still runs. A later run that reads the file can reuse the retained base and rolling files if their translator stamp and Vulkan vendor/device/cache UUID still match. Otherwise the normal stamp/header checks reject them. This preserves an existing valid cache, but does not keep it updated with the skipped run's new pipelines or make an old-driver file valid for a new driver.

The explicit RX_VK_PCACHE_LOAD=0 overwrite protection does work independently of the new default. The new retirement branch also stops the close path from writing a rolling file. The periodic-retirement problem in finding 1 is about retained memory, not a remaining overwrite path.

Measurements

The reported warm-cache comparison meets the important paired-memory conditions: named builds, the same 16 GB PC and settings, and three alternating tours per side with medians. Arithmetic from the committed run rows gives:

Published measure Main range PR range Difference of medians
Peak game resident + swapped 12,602-12,820 MB 11,867-12,014 MB -831 MB
Private memory + swap at the end 5,108-5,280 MB 4,301-4,481 MB -733 MB
Lowest system MemAvailable 271-507 MB 352-930 MB +329 MB

The first two ranges are disjoint and their median gaps exceed their within-side spreads. That supports the claimed memory reduction on this PC and tour. MemAvailable has overlapping ranges and substantial variation; it does not establish that memory pressure is solved. The reported fps difference is smaller than the spread and was explicitly not collected as a controlled timing comparison. There is no demonstrated speed gain. The reported program-load median worsens from 1.8 to 5.0 ms, and total first-use waits from 52 to 206 ms; retain all three runs' load and wait rows to show their spread, not just one excerpt and the medians. No overall startup-time improvement is shown.

A cold-driver-cache run was measured, once per side, with 10,143 and 10,901 graphics misses. However, the candidate read the file in that run. It tests the cold fallback, not the behavior of skipping the file while the relevant driver cache is cold or disabled. It also lacks repeated cold pairs.

Correct the rebase explanation. Main's intervening change includes gpu/vk/eden/shader_recompiler/ir_opt/scene_tonemap_pass.h. nx2/build.py, lines 1178-1182, hashes every file under eden into the shader stamp. That change therefore does go through cache invalidation, even though the pipeline-loading code is unchanged. Keep the numbers labelled as measured on 999bc37f; explain the changed cache identity and distinguish warmed steady-state results from the first start after updating. The measured commit was not available from the fetched refs or the public commit endpoints, so its claimed identical replay was not independently established here. Full per-run logs and memory samples are not linked in the thread.

Overlaps and remaining checks

  • #415 fixes the same explicit-off persistence problem differently: it prevents play generations from starting and guards the merge call in pcache_init(). This PR deliberately keeps generations. Do not combine those approaches unchanged: 415's guard would prevent the retirement design here from running at all and send new pipelines into the base in-memory cache. Their switch documentation and fixture cases also need one combined definition. No combined build or test was run.
  • #370 changes which sources define the translated-program stamp, not this load policy. Its exclusion of vk_api.h does not exclude the changed Eden header above. Installing its new formula causes a one-time invalidation. While this PR skips loading, the old pipeline files and stamp remain untouched; on a later loading run, normal stamp rejection still applies. Do not relabel old warm-cache evidence as a combined-stack update test.
  • Passed here: test_pcache_load, test_pipeline_play_cache (13 cases), test_pcache_stamp and test_pcache_fetch_lock, each with GCC and Clang, plus test_gpl_library_cache. No test was weakened. These are rule, file-model and source checks, not a native NVIDIA-cache reproduction.
  • Not run: the full suite, Windows execution, a full renderer build, NVK/AMD/Intel, a real disabled/read-only driver cache, a driver update, or extended play. The useful remaining evidence is an integrated periodic-retirement test, a real cache-selection fixture, and repeated longer warm/cold/disabled runs on the target low-RAM machine with the selected path, cache state, load-start marker, memory and first-use waits retained.
Read head `4fd82b75` against main `5e072fc8`: the complete eight-file diff, description, sole comment, empty reviews, issue 388 and both comments, cache readers/writers, program-load dispatch and the relevant changes in 415 and 370; ran nine game-free check invocations across five files, all passed, with GCC and Clang for the compiled checks. No game, full build or timing run. ### What's good - The cost is real. Main maps the complete base file and hands it to `vkCreatePipelineCache`; file-backed input avoids a large temporary byte vector, not the driver's retained cache. The reported memory reduction is consistent with removing that retained input. - The explicit-off overwrite fix is separate and useful. The new guard in `play_files_merge()` prevents an empty base cache plus 16 rolling files from replacing the larger base file. The new `no-save` case passes with both compilers and preserves the authored base and rolling files. - The decision is latched once, keeps an explicit override, and excludes ordinary preparation and load-before-title starts from the automatic skip. It does not change the translated-program format or shader-stamp inputs. ### Must change 1. **Reach generation retirement from the ordinary save entry point.** In `gpu/vk/vk_draw.cpp`, lines 945-949, the new no-save branch destroys retired play caches, but the periodic caller cannot reach it: `vk_replay.cpp`, line 4099, calls `pipeline_cache_save(false)`, whose first condition at `vk_draw.cpp`, line 10343, returns when `pcache_no_save` is true. `play_cache_begin()` still creates a generation, and `create_cached()` keeps adding play pipelines to it. On the PCs newly selected by this default, those additions therefore stay in the same generation until close, instead of being retired at the periodic saves as on main. Route generation retirement around the file-write prohibition while keeping the current user-count synchronization. Extend the fixture through `pipeline_cache_save(false)`, after enough new pipelines to trigger a save, rather than calling `play_cache_save()` directly. It should prove that the old cache is destroyed, new work still succeeds, and no file is written. **Traced through the source; the passing `no-save` case does not exercise this caller. No long-session memory run.** 2. **Use the selected driver's cache for the cold-cache guard.** In `gpu/vk/vk_draw.cpp`, lines 1055-1057, the new decision treats `driver_cache_bytes(nullptr)` as NVIDIA's cache size. That helper, lines 9619-9633, adds NVIDIA's and Mesa's folders together. A fresh, empty `__GL_SHADER_DISK_CACHE_PATH` with at least 512 MiB left in Mesa's folder therefore selects “file not read”, even though NVIDIA's cache is empty. This is not just the disclosed case of other programs filling NVIDIA's cache: an unrelated driver's bytes defeat the explicit cold-cache fallback. The base and rolling files are then ignored, and listed pipelines which neither live cache can answer are deferred to their first draw or dispatch (`vk_programs.cpp`, lines 240-255). Count only the selected driver's cache for this decision and treat an unavailable scan as unknown/cold. Add an adapter-level case with an empty NVIDIA folder and a populated Mesa folder, requiring the file to be read. **Traced through the source, not reproduced in a game; the new table test supplies a number directly and never exercises folder selection.** ### What the condition actually selects - The platform branch is `#ifndef _WIN32`, and the GPU check is `vendorID == 0x10DE`. On the supported platforms this means Linux with an NVIDIA GPU, not specifically NVIDIA's proprietary driver. Mesa NVK is not excluded by that check; `dev.driver_id` is already available if proprietary-driver-only is the intended scope. - RAM is `sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE)`, shifted right by 20. It is total RAM reported by the OS, not current free RAM, VRAM or a process memory allowance. Unknown RAM falls back to reading the file. The inclusive limit is **20,480 MiB, or 20 GiB**, with the byte count rounded down to MiB. A typical 16 GiB PC qualifies, including the reported 15,757 MiB machine. Typical 24 and 32 GiB PCs do not; unusually large hardware reservations can change the reported total. - `programs_load_decide()` runs after device creation and before this choice. The existing load mode matters: native mesh normally selects create, while the fallback, compressed program cache or an existing load-start marker can select start. This PR does not help the issue's original load-before-title configuration by default. - Nonempty `RX_VK_PCACHE_LOAD=0`, `off`, `false` or `no` forces the skip; `1` or another non-off value forces loading. Empty is treated as automatic. The switch wins over preparation too: `choose(0, true, ...)` skips the file, and the new test explicitly requires that. The documentation's “always by --prepare-shaders” needs that exception. - The reason line is emitted only for small-PC automatic candidates or an explicit override. Other automatic paths, including Windows, larger RAM and load-before-title, do not get that reason line. An explicit override also prints a driver-cache size of 0 without scanning it, so that number is not an observation of an empty cache. The later path/size line remains. ### Cold, disabled or unwritable driver caches A genuinely empty aggregate scan falls back to main's file-loading path. A first start without a valid warm marker also has the existing up-front preparation/warm pass, so it is not correct to say every cold first start necessarily compiles everything in play. The size check does not establish that this game's entries are present, compatible or usable. It does not check `__GL_SHADER_DISK_CACHE=0`, and it does not establish usability on a read-only home. Read-only storage alone does not prove existing entries cannot be read. NVIDIA also documents that its cached binaries are driver-version-specific: https://download.nvidia.com/XFree86/Linux-x86_64/570.124.04/README/openglenvvariables.html. These cases need separate evidence, not a directory-size inference. With an existing warm marker, a skipped file and driver misses, loads at create only probe the caches. Missing pipelines are compiled when first needed in play. More than 500 listed misses can write `longshot_load_start.txt`, making the next run load before the title and disabling this automatic memory saving. The description discloses unrelated NVIDIA entries, but “this costs nothing beyond main” is not established for disabled caches, read-only storage or other drivers. ### Files retained for the next run When the file is skipped, **neither the base file nor new rolling files are written**. Existing published files and their stamp are left alone; old temporary-file cleanup still runs. A later run that reads the file can reuse the retained base and rolling files if their translator stamp and Vulkan vendor/device/cache UUID still match. Otherwise the normal stamp/header checks reject them. This preserves an existing valid cache, but does not keep it updated with the skipped run's new pipelines or make an old-driver file valid for a new driver. The explicit `RX_VK_PCACHE_LOAD=0` overwrite protection does work independently of the new default. The new retirement branch also stops the close path from writing a rolling file. The periodic-retirement problem in finding 1 is about retained memory, not a remaining overwrite path. ### Measurements The reported warm-cache comparison meets the important paired-memory conditions: named builds, the same 16 GB PC and settings, and three alternating tours per side with medians. Arithmetic from the committed run rows gives: | Published measure | Main range | PR range | Difference of medians | |---|---:|---:|---:| | Peak game resident + swapped | 12,602-12,820 MB | 11,867-12,014 MB | -831 MB | | Private memory + swap at the end | 5,108-5,280 MB | 4,301-4,481 MB | -733 MB | | Lowest system MemAvailable | 271-507 MB | 352-930 MB | +329 MB | The first two ranges are disjoint and their median gaps exceed their within-side spreads. That supports the claimed memory reduction on this PC and tour. MemAvailable has overlapping ranges and substantial variation; it does not establish that memory pressure is solved. The reported fps difference is smaller than the spread and was explicitly not collected as a controlled timing comparison. There is no demonstrated speed gain. The reported program-load median worsens from 1.8 to 5.0 ms, and total first-use waits from 52 to 206 ms; retain all three runs' load and wait rows to show their spread, not just one excerpt and the medians. No overall startup-time improvement is shown. **A cold-driver-cache run was measured**, once per side, with 10,143 and 10,901 graphics misses. However, the candidate read the file in that run. It tests the cold fallback, not the behavior of skipping the file while the relevant driver cache is cold or disabled. It also lacks repeated cold pairs. **Correct the rebase explanation.** Main's intervening change includes `gpu/vk/eden/shader_recompiler/ir_opt/scene_tonemap_pass.h`. `nx2/build.py`, lines 1178-1182, hashes every file under `eden` into the shader stamp. That change therefore does go through cache invalidation, even though the pipeline-loading code is unchanged. Keep the numbers labelled as measured on `999bc37f`; explain the changed cache identity and distinguish warmed steady-state results from the first start after updating. The measured commit was not available from the fetched refs or the public commit endpoints, so its claimed identical replay was not independently established here. Full per-run logs and memory samples are not linked in the thread. ### Overlaps and remaining checks - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/415 fixes the same explicit-off persistence problem differently: it prevents play generations from starting and guards the merge call in `pcache_init()`. This PR deliberately keeps generations. Do not combine those approaches unchanged: 415's guard would prevent the retirement design here from running at all and send new pipelines into the base in-memory cache. Their switch documentation and fixture cases also need one combined definition. No combined build or test was run. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/370 changes which sources define the translated-program stamp, not this load policy. Its exclusion of `vk_api.h` does not exclude the changed Eden header above. Installing its new formula causes a one-time invalidation. While this PR skips loading, the old pipeline files and stamp remain untouched; on a later loading run, normal stamp rejection still applies. Do not relabel old warm-cache evidence as a combined-stack update test. - Passed here: `test_pcache_load`, `test_pipeline_play_cache` (13 cases), `test_pcache_stamp` and `test_pcache_fetch_lock`, each with GCC and Clang, plus `test_gpl_library_cache`. No test was weakened. These are rule, file-model and source checks, not a native NVIDIA-cache reproduction. - Not run: the full suite, Windows execution, a full renderer build, NVK/AMD/Intel, a real disabled/read-only driver cache, a driver update, or extended play. The useful remaining evidence is an integrated periodic-retirement test, a real cache-selection fixture, and repeated longer warm/cold/disabled runs on the target low-RAM machine with the selected path, cache state, load-start marker, memory and first-use waits retained.
Contributor

The same idea measured on AMD with RADV, a Steam Deck OLED, in case the rule goes past NVIDIA. Not this PR's code: the switch main already has, RX_VK_PCACHE_LOAD=0, against unset.

Setup. Steam Deck OLED (AMD Custom APU 0932, RADV VANGOGH, Mesa 26.2.0-devel), 16 GB shared with the GPU, SteamOS 3.9.5, kernel 7.2.7-valve2. A renderer built from main 514591a3 with renderer-only changes of other pull requests (#238, #384, #387, #391, #223's commit), programs loaded at create (RX_VK_LOAD=create), Minimum preset, handheld profile, no screen (headless). The pipeline cache file is 307 MB there. Each run starts the game and loads a save by script; memory is read from /proc/<pid>/status and /proc/meminfo at the end of the measured span, KiB divided by 1,024.

What it gives back (RssAnon, MiB, file read then not read):

read not read
heavy view, 2 alternated pairs, Mesa's cache in ~/.cache (1,489 MB) 1,698 / 1,707 1,488 / 1,464
Hyrule Field, Mesa on a copy of the cache Steam gives the game (187 MB, below) 1,717 / 1,719 / 1,818 / 1,722 1,558 / 1,518 / 1,522 / 1,543 / 1,539
Kokiri Forest, same cache 1,890 1,474 / 1,565
heavy view, same cache 1,737 1,499

About 200 to 300 MiB for a 307 MB file. MemAvailable follows (heavy view 2,488 / 2,652 against 2,762 / 2,802 MiB). GPU memory (drm-memory-gtt) does not move, and standing still the frame rate is the same (29.28 / 29.57 against 29.46 / 29.36 fps).

What it costs here.

  • Nothing drawn late: no draw left out and no wait for a shader or a pipeline in any run without the file; at most 3 first uses ran their own load (6 ms in all).
  • The loads are slower, on the workers: a program load's median goes from 0.58-0.69 ms to 1.07-1.56 ms, and the log's cumulated pipeline creation from 0.4-0.5 s to 2.1-7.1 s a run.
  • The arrival in an area, the 600 frames after a save loads (RX_VK_FRAME_TRACE=1, time spent in frames over 60 ms): Kokiri Forest 5.5 s read against 3.1 and 6.0 s; heavy view 3.2 against 3.4 s; Hyrule Field 2.5 / 2.8 / 3.5 / 2.6 s read against 3.0 / 3.4 / 3.8 / 3.5 / 2.6 s. In Hyrule Field the longest frame is about 1 s in 4 of the 5 runs without the file (514 to 1,011 ms) against 1 of the 4 with it (529 to 1,118 ms). Small samples, but on this 4-core machine the workers building pipelines seem to cost the replay while it uploads the area's textures.

For the driver cache guard (the review's point 2). On a Deck in Game Mode, Steam points Mesa at a cache of the game's own, steamapps/shadercache/<the shortcut's id>/mesa_shader_cache_sf (a single-file cache, through MESA_SHADER_CACHE_DIR), not at ~/.cache/mesa_shader_cache. On this Deck the first holds 187 MB and the second 1,489 MB (filled by headless runs started over SSH). The 187 MB one answered every pipeline in the runs above: the copy grew by 3 MB in its first run and not after. So a 512 MB threshold on a folder's size would look at the wrong folder here, and would turn down a cache that is complete. If the rule goes to Mesa, the folder to read is the one MESA_SHADER_CACHE_DIR names when it is set.

Not tested: this PR's code; a start from Steam itself (its cache was a copy, read through MESA_SHADER_CACHE_DIR and MESA_DISK_CACHE_SINGLE_FILE=1 in a headless run); a cold Mesa cache; a long session. The game folder's cache files were copied aside and put back after each series.

The same idea measured on AMD with RADV, a Steam Deck OLED, in case the rule goes past NVIDIA. Not this PR's code: the switch main already has, `RX_VK_PCACHE_LOAD=0`, against unset. **Setup.** Steam Deck OLED (AMD Custom APU 0932, RADV VANGOGH, Mesa 26.2.0-devel), 16 GB shared with the GPU, SteamOS 3.9.5, kernel 7.2.7-valve2. A renderer built from main 514591a3 with renderer-only changes of other pull requests (#238, #384, #387, #391, #223's commit), programs loaded at create (`RX_VK_LOAD=create`), Minimum preset, handheld profile, no screen (headless). The pipeline cache file is 307 MB there. Each run starts the game and loads a save by script; memory is read from `/proc/<pid>/status` and `/proc/meminfo` at the end of the measured span, KiB divided by 1,024. **What it gives back** (`RssAnon`, MiB, file read then not read): | | read | not read | |---|---|---| | heavy view, 2 alternated pairs, Mesa's cache in `~/.cache` (1,489 MB) | 1,698 / 1,707 | 1,488 / 1,464 | | Hyrule Field, Mesa on a copy of the cache Steam gives the game (187 MB, below) | 1,717 / 1,719 / 1,818 / 1,722 | 1,558 / 1,518 / 1,522 / 1,543 / 1,539 | | Kokiri Forest, same cache | 1,890 | 1,474 / 1,565 | | heavy view, same cache | 1,737 | 1,499 | About 200 to 300 MiB for a 307 MB file. `MemAvailable` follows (heavy view 2,488 / 2,652 against 2,762 / 2,802 MiB). GPU memory (`drm-memory-gtt`) does not move, and standing still the frame rate is the same (29.28 / 29.57 against 29.46 / 29.36 fps). **What it costs here.** - Nothing drawn late: no draw left out and no wait for a shader or a pipeline in any run without the file; at most 3 first uses ran their own load (6 ms in all). - The loads are slower, on the workers: a program load's median goes from 0.58-0.69 ms to 1.07-1.56 ms, and the log's cumulated pipeline creation from 0.4-0.5 s to 2.1-7.1 s a run. - The arrival in an area, the 600 frames after a save loads (`RX_VK_FRAME_TRACE=1`, time spent in frames over 60 ms): Kokiri Forest 5.5 s read against 3.1 and 6.0 s; heavy view 3.2 against 3.4 s; Hyrule Field 2.5 / 2.8 / 3.5 / 2.6 s read against 3.0 / 3.4 / 3.8 / 3.5 / 2.6 s. In Hyrule Field the longest frame is about 1 s in 4 of the 5 runs without the file (514 to 1,011 ms) against 1 of the 4 with it (529 to 1,118 ms). Small samples, but on this 4-core machine the workers building pipelines seem to cost the replay while it uploads the area's textures. **For the driver cache guard** (the review's point 2). On a Deck in Game Mode, Steam points Mesa at a cache of the game's own, `steamapps/shadercache/<the shortcut's id>/mesa_shader_cache_sf` (a single-file cache, through `MESA_SHADER_CACHE_DIR`), not at `~/.cache/mesa_shader_cache`. On this Deck the first holds 187 MB and the second 1,489 MB (filled by headless runs started over SSH). The 187 MB one answered every pipeline in the runs above: the copy grew by 3 MB in its first run and not after. So a 512 MB threshold on a folder's size would look at the wrong folder here, and would turn down a cache that is complete. If the rule goes to Mesa, the folder to read is the one `MESA_SHADER_CACHE_DIR` names when it is set. **Not tested:** this PR's code; a start from Steam itself (its cache was a copy, read through `MESA_SHADER_CACHE_DIR` and `MESA_DISK_CACHE_SINGLE_FILE=1` in a headless run); a cold Mesa cache; a long session. The game folder's cache files were copied aside and put back after each series.
tonesi changed title from perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.7-0.8 GB less) to WIP: perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.7-0.8 GB less) 2026-11-14 20:21:31 +00:00
Owner

@Beanstalk

@Beanstalk
Member

Beanstalk test farm

Commit 0863e13 · tier untrusted · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `0863e13` · tier **untrusted** · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/416) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
HumanBean added this to the v3.0.0 milestone 2026-11-14 22:49:44 +00:00
tonesi force-pushed perf/388-pcache-low-ram from 4fd82b7559
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 17s
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
beanstalk/approval approved by HumanBean (reviewed)
Website / Website on Cloudflare (pull_request) Has been cancelled
beanstalk/linux+nvidia 0/1 pass, 0 running, 1 queued
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
to 1433d4d393
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval not approved yet
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-14 22:54:23 +00:00
Compare
tonesi changed title from WIP: perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.7-0.8 GB less) to WIP: perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.8 GB less) 2026-11-14 22:56:46 +00:00
Author
Contributor

Thanks for the careful review, @mooki. Both must-change points are fixed, plus one more thing the re-measure turned up (stale files, below). The branch is rebased onto main ce9d49b4 and measured again on 414f56e2 and on 82886e89. Point by point:

1. Generation retirement from the ordinary save (61e672fd). Fixed as you described: pipeline_cache_save() no longer returns when pcache_no_save is set. It skips only the cache's own part (never fetched nor written) and still calls play_cache_save(), with the same user-count wait, so the ordinary save every 300 presents takes play's generation away and frees it, writing nothing. The fixture goes through the real entry point now: tests/test_pipeline_play_cache.py no-save-periodic extracts pipeline_cache_save too and runs pipeline_cache_save(false) into the real play caches. Under the threshold nothing happens. Past it, the generation is destroyed on the save's thread, new work goes into the next one, and the folder holds only the base file afterwards (no play file, no temporary). It fails on the previous head 4fd82b75 at the retirement (line 495) and on main, and passes with GCC and Clang. It runs over main's new between path too (b2911d33), which the rebase kept as main has it. The game logs play's generation <n> let go, not written for the first four and every 16th, and it does in the PR's tours (for example play's generation 2 let go, not written (the file not read): 21 pipelines, 9 from the driver's cache, 12 compiled).

2. The selected driver's cache for the cold-cache guard (03fd3c83). The rule counts NVIDIA's own folder alone now, the one its driver uses per its README: __GL_SHADER_DISK_CACHE_PATH's GLCache, else $XDG_CACHE_HOME/nvidia/GLCache or ~/.cache/nvidia/GLCache, or the older drivers' $XDG_CACHE_HOME/.nv/GLCache / ~/.nv/GLCache where they exist (the README says the driver reuses them). Mesa's folders don't count. A cache that is off (__GL_SHADER_DISK_CACHE an off value, or none of the three variables set, where the README says the driver keeps none), a folder that can't be walked through, one that isn't a folder, or one under 512 MB: the file is read. A folder that isn't there counts as 0. driver_cache_bytes() stays for the start's log line only.
The adapter-level case is in tests/test_pcache_load.py: pcache_load_off() itself is cut out of vk_draw.cpp, compiled with stand-ins for the driver ID, the load mode and the RAM, and run once a case against real folders (sparse 600 MB files). mesa-only is your case: a fresh, empty __GL_SHADER_DISK_CACHE_PATH with 600 MB in Mesa's folders, which reads the file. 20 cases in all, with GCC and Clang. In the game, on the PR's folder:

vk: driver shader cache at the start: 600 MB (<report>/guard-nv/GLCache 0 MB, <report>/guard-mesa 600 MB)
vk: pipeline cache file read: NVIDIA's own shader cache is nearly empty (15757 MB of RAM, NVIDIA's own shader cache 0 MB in <report>/guard-nv/GLCache)
vk: pipeline cache file read: NVIDIA's own shader cache is off (15757 MB of RAM, NVIDIA's own shader cache off (__GL_SHADER_DISK_CACHE, or no folder for it))

What the condition selects:

  • NVK: now dev.driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY, so Mesa's NVK reads the file (an nvk case in the test).
  • RAM: as you describe (total RAM, 20,480 MiB inclusive, unknown reads the file). Unchanged, and the description says "total RAM".
  • Load mode: agreed, the PR doesn't help the issue's load-before-title configuration by default; the description says so and points at #223.
  • The switch over a preparation: kept on purpose (as RX_VK_PCACHE_LOAD=0 behaved before), and the docs row now says the switch wins over --prepare-shaders too.
  • The reason line: one line on every PC now, for every path (Windows, more RAM, start mode, a preparation, the switch), with the RAM and NVIDIA's folder and size only where they were looked at. The switch's line prints no cache size (switch-on and switch-off-prepare check that).

Stale files (da116f0e). Updating main from 414f56e2 to 82886e89 changed the translator stamp (sizeof(Program), b2911d33). Main dropped its 14 pipeline cache files (1219 MB), but the PR's folder kept them, because pcache_drop_stale() returned early whenever the file wasn't read. On the PCs this rule covers, that would leave 1.2 GB of dead files on disk after every release. Those files now go whether or not the file is read (RX_VK_PCACHE_STAMP=0 still keeps them; tests/test_pcache_stamp.py checks it). The game showed it: the head's renderer on the PR's folder logged 14 files made for another translator dropped (1219 MB) and still didn't read the file. The same update is also the nearest thing to your driver-update case I could run here (a translator change, not a driver change): with the file unread, the PR's folder prepared every shader again at its first start and loaded at create from then on with 0 listed pipelines in no cache.

Cold, disabled or unwritable caches: disabled (__GL_SHADER_DISK_CACHE=0) and unreadable now read the file. A read-only cache isn't a reason to read, as you say, so the rule doesn't look at it. On driver updates: agreed that the size doesn't establish usability. What I found in the source, not run here (no second driver to try): warmed_stamp() holds driverVersion, so the first start on a new driver finds the driver's part of the shaders made for another driver and makes it again before play (prepare_run, "made again"), which is what fills NVIDIA's new-driver cache. The >500-misses fallback you describe is real. If NVIDIA's folder holds 512 MB that doesn't answer this game, misses are compiled at first use, and past 500 the marker moves the next start to loading before the title, where this rule reads the file. I took "costs nothing beyond main" out of the description; Risks now says exactly this.

Files retained: agreed with your reading. The description's Compatibility says the file and its play files stay untouched where it isn't read, for a later start that reads it, and that they aren't updated.

Measurements: measured again, three interleaved tours a side on main 414f56e2, then two comparable pairs on main 82886e89 after a warm-up pair. Every run's load and wait row is in the description now, not just one excerpt. Private memory + swap at the end: -775 MB on 414f56e2 (3 + 3) and -816 MB on 82886e89 (2 + 2), every PR run below every main run. Peak game total: -452 and -816 MB. Swap peak: -1.07 and -1.37 GB. Loads at create: 1.9-2.0 → 5.0-5.1 ms. Waits: 1-4 → 6-7 a tour. MemAvailable: I've kept it as an observation and don't claim the memory pressure is solved. fps isn't a timing comparison (the desktop's card), and the description says no speed gain.

  • Cold pairs: with the guard as it is now, a cold, off or unreadable NVIDIA cache reads the file, and with the file read the PR's code is main's: pcache_no_save is false, so play_files_merge() and both saves run as on main. Repeated cold pairs would compare main with main, so I ran the two decisions in the game instead (above).
  • The rebase explanation: you're right, and I've dropped it: the Eden header change between 0caf0618 and 5e072fc8 does change the stamp. The new numbers are from builds of main and the PR on it, with main's prepared caches handed to the PR's folder. That's right for an update to this PR because the PR changes none of the translator stamp's inputs: none of translator_files.py's stamped files (eden/, sirit/, compat/, vk_shader.cpp, vk_bank.cpp, vk_state.h), and none of the records whose sizes translator_stamp() folds in. The first start after updating main itself can translate again, which is main's change, not this PR's (82886e89 did). The measured commits are on the fork as measured/416-9ea38a42 and measured/416-f0963cdc (and measured/416-999bc37f for the first measurement), so they can be fetched. The last rebase, onto ce9d49b4, brings in only scripts/longshot_ctl.py's Windows console flag. The old runs stay in docs/tested/ labelled with 999bc37f and 0caf0618.

Overlaps: #415 is still open. I haven't combined them. Whichever lands second has to take one design: this PR keeps the generations and frees them at each save, while 415 stops them from starting (so play's pipelines go into the base cache, which isn't saved, and stay for the session). I'd keep this one's, since it gives the memory back. Then 415's merge guard in pcache_init() is redundant with play_files_merge()'s own early return here, and its play_cache_begin() guard would undo the retirement. #370 is merged. The new runs were built on it and nothing is relabelled.

Checks on the head's code: the whole suite on Linux gives 538 passed, 10 failed, 30 skipped. Main 82886e89 run the same way gives 537 passed and the same 10 failures, listed under Testing (test_crash_record passes alone on both). The Windows back end compiled and linked with the pinned llvm-mingw 20261104, and the three changed test programs compiled for Windows (syntax and one link, not run).

One more thing, in the interest of full disclosure: the short start that checked the stale-file drop (4 minutes, idle at the title) logged four NVRM lines 3 s before its timeout ended it: dmaAllocMapping_GM107: can't alloc VA space for mapping, and NV_ERR_NO_MEMORY from the mapping reuse callback. There was no device lost and nothing in the game's log. None of the other 21 game runs today, main's or the PR's, logged any. I don't understand it yet, so it's under Testing as it is.

Thanks for the careful review, @mooki. Both must-change points are fixed, plus one more thing the re-measure turned up (stale files, below). The branch is rebased onto main ce9d49b4 and measured again on 414f56e2 and on 82886e89. Point by point: **1. Generation retirement from the ordinary save** (61e672fd). Fixed as you described: `pipeline_cache_save()` no longer returns when `pcache_no_save` is set. It skips only the cache's own part (never fetched nor written) and still calls `play_cache_save()`, with the same user-count wait, so the ordinary save every 300 presents takes play's generation away and frees it, writing nothing. The fixture goes through the real entry point now: `tests/test_pipeline_play_cache.py` `no-save-periodic` extracts `pipeline_cache_save` too and runs `pipeline_cache_save(false)` into the real play caches. Under the threshold nothing happens. Past it, the generation is destroyed on the save's thread, new work goes into the next one, and the folder holds only the base file afterwards (no play file, no temporary). It fails on the previous head 4fd82b75 at the retirement (line 495) and on main, and passes with GCC and Clang. It runs over main's new `between` path too (b2911d33), which the rebase kept as main has it. The game logs `play's generation <n> let go, not written` for the first four and every 16th, and it does in the PR's tours (for example `play's generation 2 let go, not written (the file not read): 21 pipelines, 9 from the driver's cache, 12 compiled`). **2. The selected driver's cache for the cold-cache guard** (03fd3c83). The rule counts NVIDIA's own folder alone now, the one its driver uses per its README: `__GL_SHADER_DISK_CACHE_PATH`'s `GLCache`, else `$XDG_CACHE_HOME/nvidia/GLCache` or `~/.cache/nvidia/GLCache`, or the older drivers' `$XDG_CACHE_HOME/.nv/GLCache` / `~/.nv/GLCache` where they exist (the README says the driver reuses them). Mesa's folders don't count. A cache that is off (`__GL_SHADER_DISK_CACHE` an off value, or none of the three variables set, where the README says the driver keeps none), a folder that can't be walked through, one that isn't a folder, or one under 512 MB: the file is read. A folder that isn't there counts as 0. `driver_cache_bytes()` stays for the start's log line only. The adapter-level case is in `tests/test_pcache_load.py`: `pcache_load_off()` itself is cut out of `vk_draw.cpp`, compiled with stand-ins for the driver ID, the load mode and the RAM, and run once a case against real folders (sparse 600 MB files). `mesa-only` is your case: a fresh, empty `__GL_SHADER_DISK_CACHE_PATH` with 600 MB in Mesa's folders, which reads the file. 20 cases in all, with GCC and Clang. In the game, on the PR's folder: ``` vk: driver shader cache at the start: 600 MB (<report>/guard-nv/GLCache 0 MB, <report>/guard-mesa 600 MB) vk: pipeline cache file read: NVIDIA's own shader cache is nearly empty (15757 MB of RAM, NVIDIA's own shader cache 0 MB in <report>/guard-nv/GLCache) vk: pipeline cache file read: NVIDIA's own shader cache is off (15757 MB of RAM, NVIDIA's own shader cache off (__GL_SHADER_DISK_CACHE, or no folder for it)) ``` **What the condition selects:** - NVK: now `dev.driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY`, so Mesa's NVK reads the file (an `nvk` case in the test). - RAM: as you describe (total RAM, 20,480 MiB inclusive, unknown reads the file). Unchanged, and the description says "total RAM". - Load mode: agreed, the PR doesn't help the issue's load-before-title configuration by default; the description says so and points at https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/223. - The switch over a preparation: kept on purpose (as `RX_VK_PCACHE_LOAD=0` behaved before), and the docs row now says the switch wins over `--prepare-shaders` too. - The reason line: one line on every PC now, for every path (Windows, more RAM, start mode, a preparation, the switch), with the RAM and NVIDIA's folder and size only where they were looked at. The switch's line prints no cache size (`switch-on` and `switch-off-prepare` check that). **Stale files** (da116f0e). Updating main from 414f56e2 to 82886e89 changed the translator stamp (`sizeof(Program)`, b2911d33). Main dropped its 14 pipeline cache files (1219 MB), but the PR's folder kept them, because `pcache_drop_stale()` returned early whenever the file wasn't read. On the PCs this rule covers, that would leave 1.2 GB of dead files on disk after every release. Those files now go whether or not the file is read (`RX_VK_PCACHE_STAMP=0` still keeps them; `tests/test_pcache_stamp.py` checks it). The game showed it: the head's renderer on the PR's folder logged `14 files made for another translator dropped (1219 MB)` and still didn't read the file. The same update is also the nearest thing to your driver-update case I could run here (a translator change, not a driver change): with the file unread, the PR's folder prepared every shader again at its first start and loaded at create from then on with 0 listed pipelines in no cache. **Cold, disabled or unwritable caches:** disabled (`__GL_SHADER_DISK_CACHE=0`) and unreadable now read the file. A read-only cache isn't a reason to read, as you say, so the rule doesn't look at it. On driver updates: agreed that the size doesn't establish usability. What I found in the source, not run here (no second driver to try): `warmed_stamp()` holds `driverVersion`, so the first start on a new driver finds the driver's part of the shaders made for another driver and makes it again before play (`prepare_run`, "made again"), which is what fills NVIDIA's new-driver cache. The >500-misses fallback you describe is real. If NVIDIA's folder holds 512 MB that doesn't answer this game, misses are compiled at first use, and past 500 the marker moves the next start to loading before the title, where this rule reads the file. I took "costs nothing beyond main" out of the description; Risks now says exactly this. **Files retained:** agreed with your reading. The description's Compatibility says the file and its play files stay untouched where it isn't read, for a later start that reads it, and that they aren't updated. **Measurements:** measured again, three interleaved tours a side on main 414f56e2, then two comparable pairs on main 82886e89 after a warm-up pair. Every run's load and wait row is in the description now, not just one excerpt. Private memory + swap at the end: -775 MB on 414f56e2 (3 + 3) and -816 MB on 82886e89 (2 + 2), every PR run below every main run. Peak game total: -452 and -816 MB. Swap peak: -1.07 and -1.37 GB. Loads at create: 1.9-2.0 → 5.0-5.1 ms. Waits: 1-4 → 6-7 a tour. MemAvailable: I've kept it as an observation and don't claim the memory pressure is solved. fps isn't a timing comparison (the desktop's card), and the description says no speed gain. - **Cold pairs:** with the guard as it is now, a cold, off or unreadable NVIDIA cache reads the file, and with the file read the PR's code is main's: `pcache_no_save` is false, so `play_files_merge()` and both saves run as on main. Repeated cold pairs would compare main with main, so I ran the two decisions in the game instead (above). - **The rebase explanation:** you're right, and I've dropped it: the Eden header change between 0caf0618 and 5e072fc8 does change the stamp. The new numbers are from builds of main and the PR on it, with main's prepared caches handed to the PR's folder. That's right for an update to this PR because the PR changes none of the translator stamp's inputs: none of `translator_files.py`'s stamped files (`eden/`, `sirit/`, `compat/`, `vk_shader.cpp`, `vk_bank.cpp`, `vk_state.h`), and none of the records whose sizes `translator_stamp()` folds in. The first start after updating main itself can translate again, which is main's change, not this PR's (82886e89 did). The measured commits are on the fork as `measured/416-9ea38a42` and `measured/416-f0963cdc` (and `measured/416-999bc37f` for the first measurement), so they can be fetched. The last rebase, onto ce9d49b4, brings in only `scripts/longshot_ctl.py`'s Windows console flag. The old runs stay in `docs/tested/` labelled with 999bc37f and 0caf0618. **Overlaps:** https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/415 is still open. I haven't combined them. Whichever lands second has to take one design: this PR keeps the generations and frees them at each save, while 415 stops them from starting (so play's pipelines go into the base cache, which isn't saved, and stay for the session). I'd keep this one's, since it gives the memory back. Then 415's merge guard in `pcache_init()` is redundant with `play_files_merge()`'s own early return here, and its `play_cache_begin()` guard would undo the retirement. https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/370 is merged. The new runs were built on it and nothing is relabelled. Checks on the head's code: the whole suite on Linux gives 538 passed, 10 failed, 30 skipped. Main 82886e89 run the same way gives 537 passed and the same 10 failures, listed under Testing (`test_crash_record` passes alone on both). The Windows back end compiled and linked with the pinned llvm-mingw 20261104, and the three changed test programs compiled for Windows (syntax and one link, not run). One more thing, in the interest of full disclosure: the short start that checked the stale-file drop (4 minutes, idle at the title) logged four NVRM lines 3 s before its timeout ended it: `dmaAllocMapping_GM107: can't alloc VA space for mapping`, and `NV_ERR_NO_MEMORY` from the mapping reuse callback. There was no device lost and nothing in the game's log. None of the other 21 game runs today, main's or the PR's, logged any. I don't understand it yet, so it's under Testing as it is.
Author
Contributor

@p0lux, thank you for measuring it on the Deck. Two things I took from it for this PR:

  • The rule stays on NVIDIA's own driver. On the Deck the file gives back 200-300 MiB, but the arrivals look worse without it (the longest frame about 1 s in 4 of your 5 Hyrule Field runs without the file, against 1 of 4 with it), which fits the workers building pipelines competing with the replay on 4 cores. That is a trade a Mesa rule would have to measure on its own, so this PR doesn't switch Mesa (RADV, ANV, NVK): since the review it checks NVIDIA's own driver by its driver ID, not the vendor ID, so NVK is left out too.
  • The driver cache guard reads only NVIDIA's folder now, the one NVIDIA's driver itself uses (__GL_SHADER_DISK_CACHE_PATH's GLCache, else $XDG_CACHE_HOME/nvidia/GLCache or ~/.cache/nvidia/GLCache, or the older drivers' .nv/GLCache where it exists). Mesa's folders no longer count toward it. So the case you describe can't come up with this PR, but you're right that a Mesa version of the rule would have to read the folder MESA_SHADER_CACHE_DIR names, single-file cache included, and not a size under ~/.cache. I've noted it in the PR as what a Mesa follow-up needs.
@p0lux, thank you for measuring it on the Deck. Two things I took from it for this PR: - **The rule stays on NVIDIA's own driver.** On the Deck the file gives back 200-300 MiB, but the arrivals look worse without it (the longest frame about 1 s in 4 of your 5 Hyrule Field runs without the file, against 1 of 4 with it), which fits the workers building pipelines competing with the replay on 4 cores. That is a trade a Mesa rule would have to measure on its own, so this PR doesn't switch Mesa (RADV, ANV, NVK): since the review it checks NVIDIA's own driver by its driver ID, not the vendor ID, so NVK is left out too. - **The driver cache guard reads only NVIDIA's folder now**, the one NVIDIA's driver itself uses (`__GL_SHADER_DISK_CACHE_PATH`'s `GLCache`, else `$XDG_CACHE_HOME/nvidia/GLCache` or `~/.cache/nvidia/GLCache`, or the older drivers' `.nv/GLCache` where it exists). Mesa's folders no longer count toward it. So the case you describe can't come up with this PR, but you're right that a Mesa version of the rule would have to read the folder `MESA_SHADER_CACHE_DIR` names, single-file cache included, and not a size under `~/.cache`. I've noted it in the PR as what a Mesa follow-up needs.
tonesi changed title from WIP: perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.8 GB less) to perf(vk): skip the pipeline cache file on Linux NVIDIA PCs with 20 GB of RAM or less (0.8 GB less) 2026-11-14 23:01:25 +00:00
Owner

This conflicts with main now: docs/development.md and tests/test_pipeline_play_cache.py. #415 added an RX_VK_PCACHE_LOAD switch of its own (with its own table row and load-* cases in that test), which overlaps this PR's RX_VK_PCACHE_LOAD=0 or 1 row and its no-save cases, so reconciling them is a design choice I haven't made for you. Could you rebase onto current main?

This conflicts with `main` now: `docs/development.md` and `tests/test_pipeline_play_cache.py`. [#415](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/415) added an `RX_VK_PCACHE_LOAD` switch of its own (with its own table row and `load-*` cases in that test), which overlaps this PR's `RX_VK_PCACHE_LOAD=0 or 1` row and its `no-save` cases, so reconciling them is a design choice I haven't made for you. Could you rebase onto current `main`?
HumanBean left a comment

Code review of head 1433d4d3 against current main a55fc6cf. Read only: nothing built or run.

Verdict: comment. Not mergeable until the conflict with #415 is settled, and the hardware run it asks for is posted.

Earlier request for changes (mooki, 4fd82b75)

Both must-change points are answered by the new head, as the diff shows:

  1. The ordinary save still retires play's generations with the file unread: pipeline_cache_save() no longer returns on pcache_no_save. It skips only the cache's own fetch and write, and still calls play_cache_save(), which frees the generation and writes nothing. The new no-save-periodic case goes through pipeline_cache_save(false).
  2. The cold-cache guard counts NVIDIA's own folder alone, through pcache_load::nvidia_cache(). Mesa's folders never count, and a cache that is off, unreadable, not a folder or under 512 MB reads the file. NVK is out through driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY. The mesa-only case in tests/test_pcache_load.py is the one mooki described.

The measurements were also redone against newer mains, with per-run rows. That review is stale and can be dismissed once the conflict is settled.

The conflict is not a basic one

Main now has #415 (35465d12), which fixes the same RX_VK_PCACHE_LOAD=0 problem the opposite way. It stops play's generations from starting (play_cache_begin() returns on pcache_no_save), guards play_files_merge() in pcache_init(), and adds its own docs row and load-* cases. This PR keeps the generations and frees them at each save. Merged together unchanged, 415's guard in play_cache_begin() means no generation is ever made. Play's pipelines then pile into the in-memory base cache for the whole session, which is the retention this PR's second fix removes, and no-save-periodic would fail. Resolving it means dropping or rewriting 415's guard and its cases, and merging the two RX_VK_PCACHE_LOAD rows in docs/development.md. That is a design choice for the author (the PR already said it would keep its own design), so I have not pushed a fix. Please rebase onto main, keep one retirement design, and update 415's load-* cases in tests/test_pipeline_play_cache.py instead of weakening them.

The default, for Linux NVIDIA (Tier 1)

I think it is right for everyone it covers, and everyone else reads the file exactly as before:

  • It is limited to Linux with NVIDIA's proprietary driver, 20 GB of RAM or less, programs loaded at create, NVIDIA's own folder present and 512 MB or more, and not a --prepare-shaders run. Anything unknown (RAM, folder, a walk error) reads the file.
  • The failure mode is bounded. If NVIDIA's cache is big but doesn't hold this game's pipelines, they compile at first use, and more than 500 listed misses write longshot_load_start.txt, so the next start loads before the title and reads the file again.
  • With the file unread nothing is written over it, so RX_VK_PCACHE_LOAD=1 or a later start on a bigger PC still finds it. Stale files from another translator now go in both cases, as tests/test_pcache_stamp.py checks.
  • The cost is stated honestly: program loads at create go from about 2 ms to 5 ms on the load workers, and 6-7 first uses wait about 200 ms in a 7-minute tour, against 1-4 on main. Memory is 0.45-0.8 GB lower, with every PR run below every main run, on one PC (RTX 3070 Ti, 16 GB).
  • hos_main.c makes the folder that __GL_SHADER_DISK_CACHE_PATH names and gives the cache 10 GiB, so the rule's folder is the one the driver uses. Without that variable the driver's own default is walked.

Points for the author

  • The four NVRM lines (dmaAllocMapping_GM107, NV_ERR_NO_MEMORY) on the stale-file start are disclosed and not understood. The long-session run should watch for them.
  • Only one PC and one card have measured it. 8 and 12 GB Linux NVIDIA PCs, and a driver update with the old driver's cache still in the folder, were not run here (traced in source only).

Testing

  • Game-free tests exist and the author reports them passing with GCC and Clang (test_pcache_load, test_pipeline_play_cache no-save and no-save-periodic, test_pipeline_cache_save, test_pcache_stamp). The author's full suite shows the same 10 failures as main. I ran none of them.
  • Missing: the test request T-XTVW (20+ minutes on another 16 GB Linux NVIDIA PC, with and without RX_VK_PCACHE_LOAD=1) is not yet reported. The description's own Must be tested names it, so I am not approving before it is posted. The conflict also leaves no head that has been run.
  • The status check also warns that the numbers were measured on main 82886e89 while main is now far past it. The change touches none of the translator stamp's inputs, so I think the numbers still hold, but a re-run after the rebase is cheap.

Merge order: settle with 415 (already merged) first, so this PR rebases onto it.

Code review of head `1433d4d3` against current main `a55fc6cf`. Read only: nothing built or run. **Verdict: comment. Not mergeable until the conflict with https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/415 is settled, and the hardware run it asks for is posted.** ### Earlier request for changes (mooki, `4fd82b75`) Both must-change points are answered by the new head, as the diff shows: 1. The ordinary save still retires play's generations with the file unread: `pipeline_cache_save()` no longer returns on `pcache_no_save`. It skips only the cache's own fetch and write, and still calls `play_cache_save()`, which frees the generation and writes nothing. The new `no-save-periodic` case goes through `pipeline_cache_save(false)`. 2. The cold-cache guard counts NVIDIA's own folder alone, through `pcache_load::nvidia_cache()`. Mesa's folders never count, and a cache that is off, unreadable, not a folder or under 512 MB reads the file. NVK is out through `driver_id == VK_DRIVER_ID_NVIDIA_PROPRIETARY`. The `mesa-only` case in `tests/test_pcache_load.py` is the one mooki described. The measurements were also redone against newer mains, with per-run rows. That review is stale and can be dismissed once the conflict is settled. ### The conflict is not a basic one Main now has https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/415 (`35465d12`), which fixes the same `RX_VK_PCACHE_LOAD=0` problem the opposite way. It stops play's generations from starting (`play_cache_begin()` returns on `pcache_no_save`), guards `play_files_merge()` in `pcache_init()`, and adds its own docs row and `load-*` cases. This PR keeps the generations and frees them at each save. Merged together unchanged, 415's guard in `play_cache_begin()` means no generation is ever made. Play's pipelines then pile into the in-memory base cache for the whole session, which is the retention this PR's second fix removes, and `no-save-periodic` would fail. Resolving it means dropping or rewriting 415's guard and its cases, and merging the two `RX_VK_PCACHE_LOAD` rows in `docs/development.md`. That is a design choice for the author (the PR already said it would keep its own design), so I have not pushed a fix. Please rebase onto main, keep one retirement design, and update 415's `load-*` cases in `tests/test_pipeline_play_cache.py` instead of weakening them. ### The default, for Linux NVIDIA (Tier 1) I think it is right for everyone it covers, and everyone else reads the file exactly as before: - It is limited to Linux with NVIDIA's proprietary driver, 20 GB of RAM or less, programs loaded at create, NVIDIA's own folder present and 512 MB or more, and not a `--prepare-shaders` run. Anything unknown (RAM, folder, a walk error) reads the file. - The failure mode is bounded. If NVIDIA's cache is big but doesn't hold this game's pipelines, they compile at first use, and more than 500 listed misses write `longshot_load_start.txt`, so the next start loads before the title and reads the file again. - With the file unread nothing is written over it, so `RX_VK_PCACHE_LOAD=1` or a later start on a bigger PC still finds it. Stale files from another translator now go in both cases, as `tests/test_pcache_stamp.py` checks. - The cost is stated honestly: program loads at create go from about 2 ms to 5 ms on the load workers, and 6-7 first uses wait about 200 ms in a 7-minute tour, against 1-4 on main. Memory is 0.45-0.8 GB lower, with every PR run below every main run, on one PC (RTX 3070 Ti, 16 GB). - `hos_main.c` makes the folder that `__GL_SHADER_DISK_CACHE_PATH` names and gives the cache 10 GiB, so the rule's folder is the one the driver uses. Without that variable the driver's own default is walked. ### Points for the author - The four NVRM lines (`dmaAllocMapping_GM107`, `NV_ERR_NO_MEMORY`) on the stale-file start are disclosed and not understood. The long-session run should watch for them. - Only one PC and one card have measured it. 8 and 12 GB Linux NVIDIA PCs, and a driver update with the old driver's cache still in the folder, were not run here (traced in source only). ### Testing - Game-free tests exist and the author reports them passing with GCC and Clang (`test_pcache_load`, `test_pipeline_play_cache` `no-save` and `no-save-periodic`, `test_pipeline_cache_save`, `test_pcache_stamp`). The author's full suite shows the same 10 failures as main. I ran none of them. - Missing: the test request T-XTVW (20+ minutes on another 16 GB Linux NVIDIA PC, with and without `RX_VK_PCACHE_LOAD=1`) is not yet reported. The description's own Must be tested names it, so I am not approving before it is posted. The conflict also leaves no head that has been run. - The status check also warns that the numbers were measured on main `82886e89` while main is now far past it. The change touches none of the translator stamp's inputs, so I think the numbers still hold, but a re-run after the rebase is cheap. Merge order: settle with 415 (already merged) first, so this PR rebases onto it.
Owner

Tested on Linux NVIDIA. This PR's 7 commits are rebased onto main @ 43f40b87: HumanBean:rebase/pr416-on-main, if you want it. Two conflicts came up, both resolved keeping both sides:

  • docs/development.md's RX_VK_PCACHE_LOAD row;
  • tests/test_pipeline_play_cache.py's cases.

One thing needs your call. #415 landed on main with pcache_no_save || in play_cache_begin(), so with the file unread no play generations start. This PR's design keeps them and lets them go at each save, which is the opposite. Its no-save tests fail against that guard. To measure the PR as you did, my local build also removed that one guard. That commit is not in the branch above, because it would break #415's load-off* tests. The two need reconciling in the PR.

Hardware: RTX 3090, NVIDIA 620.70.06, Ryzen 9 7900X, 30 GB RAM, CachyOS.
Method: the automatic rule doesn't apply at 30 GB, so it's forced with RX_VK_PCACHE_LOAD=0 against =1, on one build and one game folder. The folder holds a real 221 MB longshot_vk_pipelines.bin, copied from a played folder. Programs load at create, interleaved, two sessions each.
Route: DLAA 2560x1440, Hyrule Field then the Market (teleports), walking and turning. Memory is the renderer's private N MB lines, plus RssAnon+RssShmem+VmSwap sampled every 2 s.

file read (=1) file not read (=0)
private peak (MB) 3,608 / 3,617 3,607 / 3,626
RssAnon+RssShmem+VmSwap peak (MB) 11,648 / 11,978 11,756 / 11,916
Program loads at create: median 1.36 / 1.26 ms 3.08 / 2.99 ms
the same: total for 5,779 loads 12.7 / 12.0 s 22.8 / 23.4 s
fps, Field turning / Market turning 80.7, 75.5 / 81.4, 71.9 81.2, 72.3 / 78.3, 73.0

On this PC, leaving the file unread saved no memory I could measure. Both counters are the same within run-to-run noise. It did cost what you measured: the median load at create went from about 1.3 ms to about 3 ms, and 10 s more in all. fps is the same. With 30 GB the page cache may keep things that a 16 GB PC under pressure would drop, so this doesn't rule out your 0.8 GB on a 16 GB PC. It only means the saving didn't reproduce here.

🤖 Generated with Claude Code

Tested on Linux NVIDIA. This PR's 7 commits are rebased onto `main` @ 43f40b87: [`HumanBean:rebase/pr416-on-main`](https://git.magicbean.dev/HumanBean/Longshot/src/branch/rebase/pr416-on-main), if you want it. Two conflicts came up, both resolved keeping both sides: - `docs/development.md`'s `RX_VK_PCACHE_LOAD` row; - `tests/test_pipeline_play_cache.py`'s cases. One thing needs your call. #415 landed on main with `pcache_no_save ||` in `play_cache_begin()`, so with the file unread no play generations start. This PR's design keeps them and lets them go at each save, which is the opposite. Its `no-save` tests fail against that guard. To measure the PR as you did, my local build also removed that one guard. That commit is **not** in the branch above, because it would break #415's `load-off*` tests. The two need reconciling in the PR. **Hardware:** RTX 3090, NVIDIA 620.70.06, Ryzen 9 7900X, **30 GB** RAM, CachyOS. **Method:** the automatic rule doesn't apply at 30 GB, so it's forced with `RX_VK_PCACHE_LOAD=0` against `=1`, on one build and one game folder. The folder holds a real 221 MB `longshot_vk_pipelines.bin`, copied from a played folder. Programs load at create, interleaved, two sessions each. **Route:** DLAA 2560x1440, Hyrule Field then the Market (teleports), walking and turning. Memory is the renderer's `private N MB` lines, plus RssAnon+RssShmem+VmSwap sampled every 2 s. | | file read (`=1`) | file not read (`=0`) | |---|---|---| | `private` peak (MB) | 3,608 / 3,617 | 3,607 / 3,626 | | RssAnon+RssShmem+VmSwap peak (MB) | 11,648 / 11,978 | 11,756 / 11,916 | | Program loads at create: median | 1.36 / 1.26 ms | **3.08 / 2.99 ms** | | the same: total for 5,779 loads | 12.7 / 12.0 s | **22.8 / 23.4 s** | | fps, Field turning / Market turning | 80.7, 75.5 / 81.4, 71.9 | 81.2, 72.3 / 78.3, 73.0 | On this PC, leaving the file unread saved no memory I could measure. Both counters are the same within run-to-run noise. It did cost what you measured: the median load at create went from about 1.3 ms to about 3 ms, and 10 s more in all. fps is the same. With 30 GB the page cache may keep things that a 16 GB PC under pressure would drop, so this doesn't rule out your 0.8 GB on a 16 GB PC. It only means the saving didn't reproduce here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Owner

A reconciliation with #415, for you to take or leave: HumanBean:rebase/pr416-on-main now has one more commit on the rebased branch (a690b1ea).

  • play_cache_begin() skips the play generations only when RX_VK_PCACHE_LOAD itself is off (0/off/...), which is #415's A/B with nothing kept. The file left unread by your automatic rule (pcache_load.h) keeps them, and play_cache_save lets each go, as you designed. So #415's load-off* cases (set through the switch) and your no-save cases (with pcache_no_save set and the switch unset) should both hold.
  • The rebase's merge of tests/pipeline_play_cache_test.cpp had kept both sides' bool pcache_no_save and std::atomic<size_t> pcache_saved_size declarations, which wouldn't compile. Each is declared once now.

I haven't run the checks on this commit (tests/test_pipeline_play_cache.py), since I can't run tests on this PC. CI on your PR will, once it's in your branch. This doesn't change the measurement above: forced on with a real 221 MB file on a 30 GB PC, it saved no memory and slowed loads at create from about 1.3 to 3 ms.

🤖 Generated with Claude Code

A reconciliation with #415, for you to take or leave: [`HumanBean:rebase/pr416-on-main`](https://git.magicbean.dev/HumanBean/Longshot/src/branch/rebase/pr416-on-main) now has one more commit on the rebased branch (a690b1ea). - `play_cache_begin()` skips the play generations only when `RX_VK_PCACHE_LOAD` itself is off (`0`/`off`/...), which is #415's A/B with nothing kept. The file left unread by your automatic rule (`pcache_load.h`) keeps them, and `play_cache_save` lets each go, as you designed. So #415's `load-off*` cases (set through the switch) and your `no-save` cases (with `pcache_no_save` set and the switch unset) should both hold. - The rebase's merge of `tests/pipeline_play_cache_test.cpp` had kept both sides' `bool pcache_no_save` and `std::atomic<size_t> pcache_saved_size` declarations, which wouldn't compile. Each is declared once now. I haven't run the checks on this commit (`tests/test_pipeline_play_cache.py`), since I can't run tests on this PC. CI on your PR will, once it's in your branch. This doesn't change the measurement above: forced on with a real 221 MB file on a 30 GB PC, it saved no memory and slowed loads at create from about 1.3 to 3 ms. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HumanBean force-pushed perf/388-pcache-low-ram from 1433d4d393
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
beanstalk/approval not approved yet
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to a690b1ea9a
Some checks failed
beanstalk/approval not approved yet
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 8s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 8s
CI / Workflow lint (actionlint) (pull_request) Successful in 10s
Third-party parts / As their notes say (pull_request) Successful in 12s
2026-11-16 16:38:56 +00:00
Compare
HumanBean force-pushed perf/388-pcache-low-ram from a690b1ea9a
Some checks failed
beanstalk/approval not approved yet
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 8s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 8s
CI / Workflow lint (actionlint) (pull_request) Successful in 10s
Third-party parts / As their notes say (pull_request) Successful in 12s
to 0863e13f53
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
beanstalk/approval not approved yet
2026-11-16 16:44:04 +00:00
Compare
Owner

I've pushed onto this branch (at the maintainer's request), so you'll want to pull before working on it again. It now holds your 7 commits rebased onto today's main (71b1edd8), plus one of mine. Head is 0863e13f, and Forgejo shows it mergeable.

Conflicts resolved:

  • docs/development.md's RX_VK_PCACHE_LOAD row and tests/test_pipeline_play_cache.py's cases: kept both sides.
  • pipeline_cache_save(): main has since added pcache_save_outcome (kNoCache, kOff, ...). I kept those lines and your rule. With the file unread the save still runs to let play's generations go, and it records kOff, which tests/test_precompile_save.py looks for.

My commit, the #415 reconciliation (described in my comment above): play_cache_begin() skips the play generations only when RX_VK_PCACHE_LOAD itself is off, which is #415's A/B. Your automatic rule keeps them. The rebase had also left pcache_no_save and pcache_saved_size declared twice in tests/pipeline_play_cache_test.cpp, so that's one of each now.

I haven't run the checks on it, since I can't run tests on my PC. CI's run on this head will say. If you'd rather have your own history back, it was 1433d4d3.

🤖 Generated with Claude Code

I've pushed onto this branch (at the maintainer's request), so you'll want to pull before working on it again. It now holds your 7 commits rebased onto today's `main` (71b1edd8), plus one of mine. Head is 0863e13f, and Forgejo shows it mergeable. **Conflicts resolved:** - `docs/development.md`'s `RX_VK_PCACHE_LOAD` row and `tests/test_pipeline_play_cache.py`'s cases: kept both sides. - `pipeline_cache_save()`: main has since added `pcache_save_outcome` (`kNoCache`, `kOff`, ...). I kept those lines and your rule. With the file unread the save still runs to let play's generations go, and it records `kOff`, which `tests/test_precompile_save.py` looks for. **My commit, the #415 reconciliation** (described in my comment above): `play_cache_begin()` skips the play generations only when `RX_VK_PCACHE_LOAD` itself is off, which is #415's A/B. Your automatic rule keeps them. The rebase had also left `pcache_no_save` and `pcache_saved_size` declared twice in `tests/pipeline_play_cache_test.cpp`, so that's one of each now. I haven't run the checks on it, since I can't run tests on my PC. CI's run on this head will say. If you'd rather have your own history back, it was 1433d4d3. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Owner

Tested for issue 388 on Linux, RTX 3090 (NVIDIA 620.70.06), with the game in a 13 GB memory cgroup (systemd-run --user --scope -p MemoryMax=13G), roughly a 16 GB PC less its desktop. This PC has 30 GB, so this PR's gate (20 GB or less) doesn't switch on here. Instead, main @ ac778751 ran with the pipeline cache file read (its default) against RX_VK_PCACHE_LOAD=0, which is what this PR makes the default on such PCs.

Route: DLAA 2560x1440, threading on Auto, a save loaded, then Hyrule Field and the Market, walking then turning, about 3 minutes of play. 2 runs each, interleaved M C C M. The cgroup's memory and swap were sampled every 2 s.

main, file read file not read (this PR's default)
cgroup memory peak 13.0, 13.0 GB (the limit) 13.0, 13.0 GB (the limit)
cgroup swap peak 0.9, 0.2 GB 0.1, 1.0 GB
Market walking fps 53.0, 48.6 52.8, 56.6
Market walking, frames over 33 ms / worst 4, 9 / 34.7, 170.6 ms 1, 1 / 45.2, 34.9 ms
Market turning fps 65.7, 60.7 61.8, 62.9

Verdict: no difference I can measure on this route. Both arms sit at the limit and swap under 1 GB. fps is the same, and the hitches are within run-to-run noise (one main run had a 171 ms frame).

This doesn't reproduce issue 388's growth. That needs the long tour: about 11 minutes through area changes, where the report's swap climbed to 15 GB. The cgroup's peak also counts page cache, which the kernel drops before it swaps. So this says the file costs nothing measurable over a short session at 13 GB, not that it doesn't matter over a long one. The memory tour of the original report (Zora's River, Zora's Domain, Hyrule Field, Kakariko) under the same limit is the test that would settle it.

🤖 Generated with Claude Code

Tested for issue 388 on Linux, RTX 3090 (NVIDIA 620.70.06), with the game in a 13 GB memory cgroup (`systemd-run --user --scope -p MemoryMax=13G`), roughly a 16 GB PC less its desktop. This PC has 30 GB, so this PR's gate (20 GB or less) doesn't switch on here. Instead, `main` @ ac778751 ran with the pipeline cache file read (its default) against `RX_VK_PCACHE_LOAD=0`, which is what this PR makes the default on such PCs. **Route:** DLAA 2560x1440, threading on Auto, a save loaded, then Hyrule Field and the Market, walking then turning, about 3 minutes of play. 2 runs each, interleaved M C C M. The cgroup's memory and swap were sampled every 2 s. | | main, file read | file not read (this PR's default) | |---|---|---| | cgroup memory peak | 13.0, 13.0 GB (the limit) | 13.0, 13.0 GB (the limit) | | cgroup swap peak | 0.9, 0.2 GB | 0.1, 1.0 GB | | Market walking fps | 53.0, 48.6 | 52.8, 56.6 | | Market walking, frames over 33 ms / worst | 4, 9 / 34.7, 170.6 ms | 1, 1 / 45.2, 34.9 ms | | Market turning fps | 65.7, 60.7 | 61.8, 62.9 | **Verdict:** no difference I can measure on this route. Both arms sit at the limit and swap under 1 GB. fps is the same, and the hitches are within run-to-run noise (one main run had a 171 ms frame). **This doesn't reproduce issue 388's growth.** That needs the long tour: about 11 minutes through area changes, where the report's swap climbed to 15 GB. The cgroup's peak also counts page cache, which the kernel drops before it swaps. So this says the file costs nothing measurable over a short session at 13 GB, not that it doesn't matter over a long one. The memory tour of the original report (Zora's River, Zora's Domain, Hyrule Field, Kakariko) under the same limit is the test that would settle it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Owner

The long tour for issue 388 on Linux, RTX 3090 (NVIDIA 620.70.06), with the game in a 13 GB memory cgroup (systemd-run --user --scope -p MemoryMax=13G), roughly a 16 GB PC less its desktop. main @ ac778751 ran with the pipeline cache file read (its default) against RX_VK_PCACHE_LOAD=0, which is what this PR makes the default on Linux NVIDIA PCs with 20 GB or less.

Route: DLAA 2560x1440, threading on Auto, a save loaded, then nine areas by the debug teleport: Zora's River, Zora's Domain, Hyrule Field, Kakariko, Death Mountain Trail, Goron City, the Market, the Lost Woods, Kokiri Forest. About 9 minutes each, interleaved M C C M. The cgroup's memory and swap were sampled every 2 s.

main, file read file not read (this PR's default)
cgroup swap peak 5.7, 5.9 GB 5.0, 6.3 GB
cgroup memory peak 11.3, 10.9 GB 11.0, 10.4 GB
frames over 33 ms / over 100 ms 274 / 35, 319 / 105 256 / 39, 862 / 267
worst frame 4.6, 9.5 s 2.2, 19.0 s

Verdict: this route reproduces the issue, but this PR doesn't change it.

  • The issue reproduces: within 13 GB the game pushes 5 to 6 GB into swap.
  • The cache file isn't the cause: with it unread, swap is the same within run-to-run noise (5.0 and 6.3 GB against 5.7 and 5.9). Hitches are no better: one run of each side is like the other, and the second unread run was the worst of all four (862 frames over 33 ms, a 19 s frame).
  • Whatever this PR saves, perhaps the 0.8 GB the description names, is small beside 5 to 6 GB of swap. I wouldn't merge it as #388's fix.

The swap comes from elsewhere. The original report's own numbers point at the private memory the game builds up while a save and its areas load (8.3 GB RssAnon at 0:31). Sampling smaps by mapping during those loads, under the same limit, is the next step: it would show which allocations they are.

🤖 Generated with Claude Code

The long tour for issue 388 on Linux, RTX 3090 (NVIDIA 620.70.06), with the game in a 13 GB memory cgroup (`systemd-run --user --scope -p MemoryMax=13G`), roughly a 16 GB PC less its desktop. `main` @ ac778751 ran with the pipeline cache file read (its default) against `RX_VK_PCACHE_LOAD=0`, which is what this PR makes the default on Linux NVIDIA PCs with 20 GB or less. **Route:** DLAA 2560x1440, threading on Auto, a save loaded, then nine areas by the debug teleport: Zora's River, Zora's Domain, Hyrule Field, Kakariko, Death Mountain Trail, Goron City, the Market, the Lost Woods, Kokiri Forest. About 9 minutes each, interleaved M C C M. The cgroup's memory and swap were sampled every 2 s. | | main, file read | file not read (this PR's default) | |---|---|---| | cgroup swap peak | 5.7, 5.9 GB | 5.0, 6.3 GB | | cgroup memory peak | 11.3, 10.9 GB | 11.0, 10.4 GB | | frames over 33 ms / over 100 ms | 274 / 35, 319 / 105 | 256 / 39, 862 / 267 | | worst frame | 4.6, 9.5 s | 2.2, 19.0 s | **Verdict:** this route reproduces the issue, but this PR doesn't change it. - **The issue reproduces:** within 13 GB the game pushes 5 to 6 GB into swap. - **The cache file isn't the cause:** with it unread, swap is the same within run-to-run noise (5.0 and 6.3 GB against 5.7 and 5.9). Hitches are no better: one run of each side is like the other, and the second unread run was the worst of all four (862 frames over 33 ms, a 19 s frame). - **Whatever this PR saves**, perhaps the 0.8 GB the description names, is small beside 5 to 6 GB of swap. I wouldn't merge it as #388's fix. The swap comes from elsewhere. The original report's own numbers point at the private memory the game builds up while a save and its areas load (8.3 GB `RssAnon` at 0:31). Sampling `smaps` by mapping during those loads, under the same limit, is the next step: it would show which allocations they are. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HumanBean deleted branch perf/388-pcache-low-ram 2026-11-16 22:28:51 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!416
No description provided.