perf(host): on Linux 6.10+ the code warm touches cached code a run at a time, not a page at a time #3087

Merged
HumanBean merged 16 commits from klimovich008/Longshot:perf/code-warm-populate into main 2026-12-03 15:26:42 +00:00
Member

Summary

Why: on Linux, the code warm thread (host/code_warm.c, HOS_CODE_WARM, on by default) keeps the game's code in memory. Every 2 s it asks mincore which pages of the program's text are cached and reads one byte of each through the kernel (process_vm_readv). That keeps the pages from being let go and faulted back in the middle of guest code. Reading page by page is expensive where much of the text stays cached. On a Steam Deck OLED at 15 W, in play, a pass over the game's 750 MB took 335 ms every 2 s: 14 % of a core, at nice 19, all the time.

What changes:

  • host/code_warm.c, on Linux 6.10 and later: each run of cached pages, up to 64 KB, is touched with one madvise(MADV_POPULATE_READ) instead of a copy per page.
    • The kernel walks the run as a read of each page would. Each page is marked accessed, as the copy does: after either way, smaps counts every page Referenced.
  • Pages that are not cached are left alone, as before. A run that fails is copied a page at a time, exactly as before, so a page unmapped or protected between mincore and the call is skipped page by page. Examples: ENOMEM or EINVAL from an unmap or mprotect, EFAULT, EINTR.
  • Why 64 KB: the call holds the mmap lock for reading over its run, so a game thread's mmap or munmap waits for at most 64 KB of it (16 pages of 4 KB, or one page where pages are 64 KB). A pass with that cap took 48 ms, against 42 ms uncapped, out of play.
  • Why 6.10: before kernel commit 631426ba1d45 (during 6.9's release candidates), a page whose read from disk kept failing made the call retry for ever, so 6.9 is left out whole. Before 6.10, and where the kernel doesn't know the advice (an empty-range probe), nothing changes: a page at a time.
  • The copy's fallback: where process_vm_readv is refused (ENOSYS, or EPERM under a sandbox), the copy reads /proc/self/mem, as before.
  • New switch: HOS_CODE_WARM_COPY=1 (off by default) copies a page at a time as before the runs, everywhere. It is read on the starting thread: a getenv on the warm thread could race a setenv of the start-up. HOS_CODE_WARM=0 still turns the thread off.
  • The log line says which way runs: by runs: N calls a pass, M failed since the last line (those runs copied page by page), or a page at a time.
  • gpu/vk/switches.def (the new row), docs/dev/reference/architecture.md (the code warm's paragraph).
  • tests/code_warm_pass_test.c and tests/test_code_warm.py: see Testing.

Result: on the Steam Deck the code warm's pass takes 57 ms instead of 335 ms, and the thread uses 2.7 % of a core instead of 14 % (below). Frame rate does not change measurably: the thread runs at nice 19. The gain is CPU time and power the game doesn't spend.

Unchanged:

  • Windows and macOS (the file is Linux only).
  • Which pages are kept: the same mincore picks, in the same 2 MB steps.
  • Nothing under gpu/ but the switch's row, which is not in the shader stamp, so no player prepares shaders again.

Read first: touch_runs and populate_supported_for in host/code_warm.c, then warm_thread.

Testing

Tested: in the game on a Steam Deck OLED (SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV, 4 cores / 8 threads, AC power, stock 15 W). The PR at 4d4a6ceb (on main b4d56f52) was built from source on the Deck, against main 2ca7d4f74. The head since then is that commit rebased onto main 1e782fa4, plus comments; the PR's files changed by comments only. Market as a child, uncapped, the Deck's harness:

  • The thread's CPU: the code warm thread's user and system time from /proc, over a 20 s window in play.
    • main: 2.77 CPU-s, 13.8 % of a core.
    • This PR: 0.54 CPU-s, 2.7 %.
    • This PR with HOS_CODE_WARM_COPY=1: 2.89 CPU-s, 14.4 %, the copy as before.
    • The PR's run was refused by the fps harness for swapping (84 MB in), but the thread's time and its pass match its other runs.
  • Its log line: 750 MB of the game's code kept in memory, of 750 MB in 1 mappings; a pass 56.7 ms every 2 s, by runs: 12002 calls a pass, 0 failed. main: a pass 335.1 ms.
    • Where only the code the game ran stayed cached (~236 MB, later runs under memory pressure): main 105 ms, this PR 28-30 ms, 3459-4086 calls a pass, 0 failed.
  • An earlier head, same build: with and without HOS_CODE_WARM_COPY=1, 3 pairs: a pass 311-348 ms against 47-58 ms.
  • No failed runs in any log line, no crash, the game clock 1.000 to 1.002.

Game-free, on the Deck:

  • tests/test_code_warm.py: passes. The pass test (tests/code_warm_pass_test.c, up to three runs) builds the real code_warm.c and checks:

    • Real pages: over memfd mappings with uncached pages and holes, the runs touch exactly the cached pages, call by call. No call is longer than 64 KB, and pagemap shows the pages mapped afterwards.
    • The version gate: 6.8 and 6.9 (including 6.9-rc4) say no; this kernel's answer matches its release; with the switch on, the copy is chosen.
    • Failed runs: a page made PROT_NONE, and a page unmapped, between mincore and the call: the run is copied page by page and the bad page skipped.
    • The sandbox: a forked child under a seccomp filter that refuses process_vm_readv gets the copy through /proc/self/mem.
    • A race: a thread unmapping and remapping the range under 10,000 passes, both ways, faults neither.
    • What the environment allows: the test asks the code itself on scratch memory and leaves out, with a line, what it cannot do. Checked under seccomp filters refusing process_vm_readv (EPERM, EACCES) and madvise (EPERM, ENOSYS): each passes.
    • Source checks: the switch is read on the starting thread, and the thread uses the choice.
  • Negative controls: each mutation below was put into a copy of code_warm.c, and the test fails on each:

    • no cap; a 68 KB cap; one byte too many;
    • a fallback on EINVAL only; stopping after a failure; the /proc/self/mem descriptor lost (in touch_runs, and in warm_range); no EPERM fallback; every call failing;
    • no version gate; the gate unused; no probe;
    • the switch ignored; the thread ignoring the switch.
  • tests/run_all.py, the whole suite, on main 238f4f65: 731 passed, 8 failed, 146 skipped. main 238f4f65 on the same Deck: the same 731 and the same 8 failed. They come from this Deck's toolchain, not the change:

    • no ASan runtime: test_audio_source, test_obj_cache_size, test_obj_guest_id, test_obj_table_bounded;
    • test_check_cache, test_game_font, test_vk_wb_cpu_words_fast;
    • test_i18n_complete: missing translations, main's.
  • Rebased since onto main 1e782fa4: no file of this PR changed, and tests/test_code_warm.py passes there.

  • pre-commit (as mise run lint; gitleaks not installed here): passes.

  • Windows: not built here. Every change is inside #if defined(__linux__) or the file's first comment, so Windows compiles the same hos_code_warm_start(void) {} as main.

  • A second-opinion review (gpt-6.2-sol), 15 rounds over the whole diff. It found and this fixed:

    • the mmap lock held over 2 MB;
    • a lasting switch to the copy after one EINVAL;
    • failed runs skipped instead of copied;
    • the kernel's retry loop before 6.10;
    • 1 MiB calls with 64 KB pages;
    • a getenv on the warm thread;
    • test environments.

    Round 15 (4d4a6ceb) found none.

Still to test:

  • linux+radv and linux+nvidia: start the game and play a minute, expecting the code: log line to say by runs: ... 0 failed on a 6.10+ kernel (a page at a time on an older one), and no crash (@Beanstalk)
  • steamdeck: the same, expecting by runs with 0 failed and no crash (@Beanstalk)

Measurements

Verdict: the code warm thread uses a fifth of the CPU it did on the Steam Deck: 2.7 % of a core instead of 13.8 %. A pass takes 57 ms instead of 335 ms, with all 750 MB of text cached. Whole-game fps doesn't change measurably (+0.8 %, the pairs disagreeing in sign), as expected for a nice-19 thread.

Setup: Steam Deck OLED, SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV, stock 15 W, AC; Market as a child, uncapped (HOS_FPS_MAX=240), headless as the farm starts it, 1280x720 at 75 %, the Deck's thread shape. The thread's CPU: one run each, /proc/<pid>/task/*/stat over a 20 s window in play. The pass: the game's own log line. fps: 3 alternating pairs, 2 admitted on each side (one PR run swapped 120 MB in and was refused), a 20 s window each, the median. The PR's build is 4d4a6ceb (on main b4d56f52, one menu commit after 2ca7d4f74); the head differs from it by a rebase and comments.

Before: main @ 2ca7d4f74 After, HOS_CODE_WARM_COPY=1: this PR @ 4d4a6ceb After: this PR @ 4d4a6ceb
code warm thread, % of a core 13.8 14.4 2.7
a pass (ms), 750 MB cached 335.1 335.4 56.7
Before: main @ 2ca7d4f74 After: this PR @ 4d4a6ceb
fps 40.10 40.43
CPU ms a frame 84.06 82.48
1 % low (fps) 21.75 23.2
p99 frame (ms) 40.93 39.17
GPU ms 12.2 12.05

HOS_CODE_WARM_COPY ships off: the copy costs five times the CPU for the same pages.

Risks

  • What could break: only Linux 6.10 and later, only the code warm thread's way of touching its pages.
    • The kernel reads a run that is no longer cached from disk, with its readahead, where the copy read single pages. That only happens for pages let go between the look and the call, as before.
    • A call that fails falls back to the copy for that run.
    • A game thread's mmap or munmap can wait behind one call, of at most 64 KB.
  • How to turn it off: HOS_CODE_WARM_COPY=1 brings back the copy; HOS_CODE_WARM=0 turns the thread off. A revert is enough.
  • What a player notices after updating: nothing but less CPU on that thread. No save, setting or cache changes, and shaders are not prepared again.
  • Pre-existing, not changed here:
    • Where the player can neither write the program file nor own it, mincore counts every page as cached, so both ways read the whole text in.
    • Right after a build writes the program, all 750 MB is cached and kept, where the game runs ~236 MB of it. Under the Deck's memory pressure in Market, those pages compete with the game's own memory. That is a separate question: a follow-up, not this PR.

Not covered:

  • Kernels 6.10 to 7.1 in the game (the Deck runs 7.2.7; the gate and the fallback are tested).
  • Kernels with 64 KB pages (the cap then gives one page a call; the test runs at this machine's 4 KB pages).
  • A filesystem other than ext4 under the game (the test's pages are memfd).

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg

## Summary **Why:** on Linux, the code warm thread (`host/code_warm.c`, `HOS_CODE_WARM`, on by default) keeps the game's code in memory. Every 2 s it asks `mincore` which pages of the program's text are cached and reads one byte of each through the kernel (`process_vm_readv`). That keeps the pages from being let go and faulted back in the middle of guest code. Reading page by page is expensive where much of the text stays cached. On a Steam Deck OLED at 15 W, in play, a pass over the game's 750 MB took 335 ms every 2 s: 14 % of a core, at nice 19, all the time. **What changes:** - `host/code_warm.c`, on Linux 6.10 and later: each run of cached pages, up to 64 KB, is touched with one `madvise(MADV_POPULATE_READ)` instead of a copy per page. - The kernel walks the run as a read of each page would. Each page is marked accessed, as the copy does: after either way, smaps counts every page Referenced. - Pages that are not cached are left alone, as before. A run that fails is copied a page at a time, exactly as before, so a page unmapped or protected between `mincore` and the call is skipped page by page. Examples: `ENOMEM` or `EINVAL` from an unmap or `mprotect`, `EFAULT`, `EINTR`. - **Why 64 KB:** the call holds the mmap lock for reading over its run, so a game thread's `mmap` or `munmap` waits for at most 64 KB of it (16 pages of 4 KB, or one page where pages are 64 KB). A pass with that cap took 48 ms, against 42 ms uncapped, out of play. - **Why 6.10:** before kernel commit 631426ba1d45 (during 6.9's release candidates), a page whose read from disk kept failing made the call retry for ever, so 6.9 is left out whole. Before 6.10, and where the kernel doesn't know the advice (an empty-range probe), nothing changes: a page at a time. - **The copy's fallback:** where `process_vm_readv` is refused (`ENOSYS`, or `EPERM` under a sandbox), the copy reads `/proc/self/mem`, as before. - **New switch:** `HOS_CODE_WARM_COPY=1` (off by default) copies a page at a time as before the runs, everywhere. It is read on the starting thread: a `getenv` on the warm thread could race a `setenv` of the start-up. `HOS_CODE_WARM=0` still turns the thread off. - The log line says which way runs: `by runs: N calls a pass, M failed since the last line (those runs copied page by page)`, or `a page at a time`. - `gpu/vk/switches.def` (the new row), `docs/dev/reference/architecture.md` (the code warm's paragraph). - `tests/code_warm_pass_test.c` and `tests/test_code_warm.py`: see Testing. **Result:** on the Steam Deck the code warm's pass takes 57 ms instead of 335 ms, and the thread uses 2.7 % of a core instead of 14 % (below). Frame rate does not change measurably: the thread runs at nice 19. The gain is CPU time and power the game doesn't spend. **Unchanged:** - Windows and macOS (the file is Linux only). - Which pages are kept: the same `mincore` picks, in the same 2 MB steps. - Nothing under `gpu/` but the switch's row, which is not in the shader stamp, so no player prepares shaders again. Read first: `touch_runs` and `populate_supported_for` in `host/code_warm.c`, then `warm_thread`. ## Testing **Tested:** in the game on a Steam Deck OLED (SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV, 4 cores / 8 threads, AC power, stock 15 W). The PR at 4d4a6ceb (on main b4d56f52) was built from source on the Deck, against main 2ca7d4f74. The head since then is that commit rebased onto main 1e782fa4, plus comments; the PR's files changed by comments only. Market as a child, uncapped, the Deck's harness: - **The thread's CPU:** the `code warm` thread's user and system time from `/proc`, over a 20 s window in play. - main: 2.77 CPU-s, 13.8 % of a core. - This PR: 0.54 CPU-s, 2.7 %. - This PR with `HOS_CODE_WARM_COPY=1`: 2.89 CPU-s, 14.4 %, the copy as before. - The PR's run was refused by the fps harness for swapping (84 MB in), but the thread's time and its pass match its other runs. - **Its log line:** `750 MB of the game's code kept in memory, of 750 MB in 1 mappings; a pass 56.7 ms every 2 s, by runs: 12002 calls a pass, 0 failed`. main: `a pass 335.1 ms`. - Where only the code the game ran stayed cached (~236 MB, later runs under memory pressure): main 105 ms, this PR 28-30 ms, 3459-4086 calls a pass, 0 failed. - **An earlier head, same build:** with and without `HOS_CODE_WARM_COPY=1`, 3 pairs: a pass 311-348 ms against 47-58 ms. - No failed runs in any log line, no crash, the game clock 1.000 to 1.002. Game-free, on the Deck: - `tests/test_code_warm.py`: passes. The pass test (`tests/code_warm_pass_test.c`, up to three runs) builds the real `code_warm.c` and checks: - **Real pages:** over memfd mappings with uncached pages and holes, the runs touch exactly the cached pages, call by call. No call is longer than 64 KB, and pagemap shows the pages mapped afterwards. - **The version gate:** 6.8 and 6.9 (including 6.9-rc4) say no; this kernel's answer matches its release; with the switch on, the copy is chosen. - **Failed runs:** a page made `PROT_NONE`, and a page unmapped, between `mincore` and the call: the run is copied page by page and the bad page skipped. - **The sandbox:** a forked child under a seccomp filter that refuses `process_vm_readv` gets the copy through `/proc/self/mem`. - **A race:** a thread unmapping and remapping the range under 10,000 passes, both ways, faults neither. - **What the environment allows:** the test asks the code itself on scratch memory and leaves out, with a line, what it cannot do. Checked under seccomp filters refusing `process_vm_readv` (`EPERM`, `EACCES`) and `madvise` (`EPERM`, `ENOSYS`): each passes. - **Source checks:** the switch is read on the starting thread, and the thread uses the choice. - **Negative controls:** each mutation below was put into a copy of `code_warm.c`, and the test fails on each: - no cap; a 68 KB cap; one byte too many; - a fallback on `EINVAL` only; stopping after a failure; the `/proc/self/mem` descriptor lost (in `touch_runs`, and in `warm_range`); no `EPERM` fallback; every call failing; - no version gate; the gate unused; no probe; - the switch ignored; the thread ignoring the switch. - `tests/run_all.py`, the whole suite, on main 238f4f65: 731 passed, 8 failed, 146 skipped. main 238f4f65 on the same Deck: the same 731 and the same 8 failed. They come from this Deck's toolchain, not the change: - no ASan runtime: `test_audio_source`, `test_obj_cache_size`, `test_obj_guest_id`, `test_obj_table_bounded`; - `test_check_cache`, `test_game_font`, `test_vk_wb_cpu_words_fast`; - `test_i18n_complete`: missing translations, main's. - Rebased since onto main 1e782fa4: no file of this PR changed, and `tests/test_code_warm.py` passes there. - pre-commit (as `mise run lint`; gitleaks not installed here): passes. - Windows: not built here. Every change is inside `#if defined(__linux__)` or the file's first comment, so Windows compiles the same `hos_code_warm_start(void) {}` as main. - A second-opinion review (gpt-6.2-sol), 15 rounds over the whole diff. It found and this fixed: - the mmap lock held over 2 MB; - a lasting switch to the copy after one `EINVAL`; - failed runs skipped instead of copied; - the kernel's retry loop before 6.10; - 1 MiB calls with 64 KB pages; - a `getenv` on the warm thread; - test environments. Round 15 (4d4a6ceb) found none. **Still to test:** - linux+radv and linux+nvidia: start the game and play a minute, expecting the `code:` log line to say `by runs: ... 0 failed` on a 6.10+ kernel (`a page at a time` on an older one), and no crash (@Beanstalk) - steamdeck: the same, expecting `by runs` with 0 failed and no crash (@Beanstalk) ## Measurements **Verdict:** the code warm thread uses a fifth of the CPU it did on the Steam Deck: 2.7 % of a core instead of 13.8 %. A pass takes 57 ms instead of 335 ms, with all 750 MB of text cached. Whole-game fps doesn't change measurably (+0.8 %, the pairs disagreeing in sign), as expected for a nice-19 thread. Setup: Steam Deck OLED, SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV, stock 15 W, AC; Market as a child, uncapped (`HOS_FPS_MAX=240`), headless as the farm starts it, 1280x720 at 75 %, the Deck's thread shape. The thread's CPU: one run each, `/proc/<pid>/task/*/stat` over a 20 s window in play. The pass: the game's own log line. fps: 3 alternating pairs, 2 admitted on each side (one PR run swapped 120 MB in and was refused), a 20 s window each, the median. The PR's build is 4d4a6ceb (on main b4d56f52, one menu commit after 2ca7d4f74); the head differs from it by a rebase and comments. | | Before: main @ 2ca7d4f74 | After, HOS_CODE_WARM_COPY=1: this PR @ 4d4a6ceb | After: this PR @ 4d4a6ceb | |---|---|---|---| | code warm thread, % of a core | 13.8 | 14.4 | 2.7 | | a pass (ms), 750 MB cached | 335.1 | 335.4 | 56.7 | | | Before: main @ 2ca7d4f74 | After: this PR @ 4d4a6ceb | |---|---|---| | fps | 40.10 | 40.43 | | CPU ms a frame | 84.06 | 82.48 | | 1 % low (fps) | 21.75 | 23.2 | | p99 frame (ms) | 40.93 | 39.17 | | GPU ms | 12.2 | 12.05 | `HOS_CODE_WARM_COPY` ships off: the copy costs five times the CPU for the same pages. ## Risks - **What could break:** only Linux 6.10 and later, only the code warm thread's way of touching its pages. - The kernel reads a run that is no longer cached from disk, with its readahead, where the copy read single pages. That only happens for pages let go between the look and the call, as before. - A call that fails falls back to the copy for that run. - A game thread's `mmap` or `munmap` can wait behind one call, of at most 64 KB. - **How to turn it off:** `HOS_CODE_WARM_COPY=1` brings back the copy; `HOS_CODE_WARM=0` turns the thread off. A revert is enough. - **What a player notices after updating:** nothing but less CPU on that thread. No save, setting or cache changes, and shaders are not prepared again. - **Pre-existing, not changed here:** - Where the player can neither write the program file nor own it, `mincore` counts every page as cached, so both ways read the whole text in. - Right after a build writes the program, all 750 MB is cached and kept, where the game runs ~236 MB of it. Under the Deck's memory pressure in Market, those pages compete with the game's own memory. That is a separate question: a follow-up, not this PR. **Not covered:** - Kernels 6.10 to 7.1 in the game (the Deck runs 7.2.7; the gate and the fallback are tested). - Kernels with 64 KB pages (the cap then gives one page a call; the test runs at this machine's 4 KB pages). - A filesystem other than ext4 under the game (the test's pages are memfd). ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
On the Steam Deck the game's 750 MB of text stays cached, so the code warm's pass copied ~157k pages one byte at a
time through process_vm_readv: 250-330 ms every 2 s in play, 2.5 CPU-s of kernel time in 20 s (13-16 % of a core,
the game's seventh-busiest thread). madvise(MADV_POPULATE_READ) over each run of pages mincore found cached marks
them accessed the same way (smaps Referenced after a clear: all of them, as with the copy) in a third of the time
(47 ms against 156 ms for 926 MB, out of play). The copy stays where the kernel refuses the advice (EINVAL: before
5.14) and as HOS_CODE_WARM_COPY=1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's review of the runs: a run is at most 16 pages, so a game thread's mmap or munmap never waits behind a 2 MB
walk (48 ms a pass against 42 uncapped, on the Deck out of play); any failed run (an unmap or mprotect after mincore:
ENOMEM, EINVAL; EFAULT, EINTR) is copied page by page, so its pages are neither skipped nor left uncounted; and whether the
kernel has MADV_POPULATE_READ is asked once with an empty range, so one mapping's EINVAL no longer turns the runs off for
the session. The pass test runs both ways where the kernel has the advice and the copy alone where it has not, and adds
runs longer than one call and a run with a page made unreadable after mincore.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's second round: before Linux 6.9 (the kernel's 631426ba1d45) MADV_POPULATE_READ could retry for ever on a page
whose read back from the disk keeps failing, so the runs are used from 6.9 on and the copy before. The pass test counts
the madvise calls (four for runs of 5, 16, 8 and 9 pages: a run over 16 pages fails it) and adds a run with a page
unmapped after mincore (ENOMEM: a fallback narrowed to EINVAL fails it); the run-failure cases run only where the runs
are used. The log line says how many calls a pass made. The comment says what was so before the runs too: where the
player neither owns nor can write the program, mincore counts every page cached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's third round: the kernel's retry fix landed during 6.9's release candidates, so 6.9 is left out whole; the
runs test is 32 pages, one 2 MB chunk even with 64 KB pages (with 40 a run split at the chunk's end and the call count
changed); switches.def and architecture.md say the gate (6.10, and a run that fails); the thread's chunk comment no
longer calls the touch its only disk read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's fourth round: a run is at most 64 KB (run_pages: 16 pages of 4 KB, one of 64 KB), not 16 pages; the pass test
expects the calls the page size gives and no failed call (a kernel that refused every run would have passed by the
copy), and one failed call in each failure case; the log line says the calls a pass and how many failed only when the
runs are used; HOS_CODE_WARM's row names the 6.10 gate, and the copy's descriptions name /proc/self/mem, the read used
where the game's sandbox refuses process_vm_readv.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's fifth round: the expected call count comes from 64 KB itself, not the code's run_pages; on Linux 6.10 and
later the test fails if populate_supported() says no where the kernel knows the advice (the runs' checks would else be
skipped without a word), and it prints whether the runs were tested; it says why the failure cases prove the copy only
with pages under 64 KB. The log line counts failed calls without claiming their copy read anything.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's sixth round, each a way the test passed on wrong code, each now failing on that mutation: the largest call
must be exactly 64 KB's pages (a 68 KB cap passed the count); the gate is populate_release_ok(), checked on 6.10, 6.12,
7.2 and refused on 6.9-rc4, 6.9.12, 6.8, 5.15, 5.14; the choice is populate_chosen(), checked with HOS_CODE_WARM_COPY at
1, 0 and unset; and a child under a seccomp filter that refuses process_vm_readv, as the game's sandbox does, must still
count a failed run's readable pages through /proc/self/mem (skipped with a line where no filter can be installed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's seventh round: the runs' expectations come from what mincore says is cached (with shmem_enabled=always a
large folio can cache the two unwritten pages, and a correct pass then keeps more than 30), still requiring a run over
the 64 KB cap; the sandboxed copy is skipped, with a line, where an outer filter kills the child on seccomp (SIGSYS) or
the container refuses /proc/self/mem. Eight mutations still fail the test (no cap, a 68 KB cap, a fallback only on
EINVAL, the descriptor lost, every call failing, no kernel gate, the switch ignored, the probe off).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's eighth round: the test wraps madvise (a #define before it includes code_warm.c) and checks the most bytes
one MADV_POPULATE_READ asked for, so a call one byte over 64 KB fails; the sandboxed child runs warm_range both ways
over five cached pages with the middle one PROT_NONE and must count what /proc/self/mem can read, so warm_range must
hand the copy its descriptor and the copy must fall back on EPERM, with 4 KB or 64 KB pages; the runs case takes its own
look at what is cached and is tried up to three times, so a page reclaimed between the look and the pass fails it once,
not for good. The code keeps no byte counter of its own now. Eleven mutations fail the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's ninth round: the two-page case allows a large shmem folio that caches the unwritten page (both touched
then); the runs case writes its pages again before each look, so a page reclaimed since is cached again and a retry
can pass; the kernel gate is populate_supported_for(release), checked on 6.8 and 6.9-rc4 and against the running
kernel; a hand-made run list checks that the runs after a failed call are still taken; the sandboxed copy runs on every
kernel, not only where the runs are on. Thirteen mutations fail the test. Not covered, as on main: the thread's loop
itself (its choice is one call to populate_chosen(), which is).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's tenth round: the warm thread's getenv could race a setenv during the renderer's start-up (glibc before
2.40 can read a freed environment array then). hos_code_warm_start reads the switch, as it reads HOS_CODE_WARM, and hands
it to the thread; populate_chosen takes it as an argument, and the source check makes sure the thread uses it. The
failure cases' runs are made by hand, not by mincore, so a page reclaimed before the look cannot take the failing call's
page out of its run; the sandboxed warm_range is tried up to three times with its pages written again first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's eleventh round, more of one kind: memory pressure on the machine can reclaim one of the test's own pages
between a look and a check (the page cache after a pass, a PTE before the pagemap check), as it could on main's test.
Each such race is closed or narrowed in the test, and test_code_warm.py runs the pass test up to three times and says
so when a later run passed: a wrong pass fails every run. The two-page case writes its page again before each pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's twelfth round: where process_vm_readv is refused (some sandboxes), the two-page and runs cases' copy counted
nothing, as main's two-page case would have. They now pass the copy /proc/self/mem, as the thread does, and the
failed-run cases, which count what process_vm_readv reads, are left to the sandboxed child there. Checked here under a
seccomp filter refusing process_vm_readv: passes, as without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's thirteenth round: on a kernel built without madvise (CONFIG_ADVISE_SYSCALLS=n) the cases cannot set up their
pages, and the thread can only copy: the test says so and stops. Where neither process_vm_readv nor /proc/self/mem
reads, the copy rightly touches nothing: its passes are left out, with a line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
From sol's fourteenth round, more filters that refuse a call the test uses (process_vm_readv with EACCES, madvise with
EPERM, small preads): the test now asks the code on scratch memory, whatever the errno, before it expects anything:
copy_reads_here (the code's own copy_pages over one page, as the thread would) decides whether the copy's passes and the
sandboxed child run, madvise_works (MADV_DONTNEED) whether the cases can be made at all. Checked here under seccomp
filters refusing process_vm_readv (EPERM, EACCES) and madvise (EPERM, ENOSYS): each leaves out what it makes impossible,
with a line, and passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
docs(host): the code warm's comments within 120 columns, with the pass when only the code the game ran stays
Some checks reported errors
beanstalk/approval approved by klimovich008 (reviewed)
beanstalk/linux+radv 0/1 pass, 2 error
beanstalk/linux+nvidia 0/1 pass, 1 error
beanstalk/steamdeck 0/1 pass, 2 error
CI / What the change needs (pull_request) Successful in 8s
CI / Third-party parts and guide screenshots (pull_request) Successful in 12s
PR description / Title and description (pull_request_target) Successful in 6s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m12s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 17m2s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 13m12s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 13m1s
CI / Website build and checks (pull_request) Successful in 1m21s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m6s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Successful in 49m49s
a3d0abdce6
Comments only, and the log line's format split over two lines. The Deck's later runs kept ~236 MB (only the code the
game ran, once memory pressure let the rest go) rather than 750 MB (all of it, as after a build wrote it): a pass took
105 ms by the copy against 28-30 ms by runs there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MibRabbL9JhKKrsNVaBfg
Author
Member

Tested in game: Steam Deck OLED (SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV), stock 15 W, AC: Market as a child, uncapped, headless, the PR built from source (4d4a6ceb) against main 2ca7d4f74. The code warm's log: 'a pass 56.7 ms every 2 s, by runs: 12002 calls a pass, 0 failed' (main: 335.1 ms); its thread 2.7 % of a core against 13.8 % on main (14.4 % with HOS_CODE_WARM_COPY=1). No crash, game clock 1.000-1.002, fps as main.

Tested in game: Steam Deck OLED (SteamOS 3.9.5, kernel 7.2.7, Mesa 26.2.0-devel RADV), stock 15 W, AC: Market as a child, uncapped, headless, the PR built from source (4d4a6ceb) against main 2ca7d4f74. The code warm's log: 'a pass 56.7 ms every 2 s, by runs: 12002 calls a pass, 0 failed' (main: 335.1 ms); its thread 2.7 % of a core against 13.8 % on main (14.4 % with HOS_CODE_WARM_COPY=1). No crash, game clock 1.000-1.002, fps as main.
Author
Member

@Beanstalk linux (RADV and NVIDIA) and the Steam Deck, this PR's head: start the game and play a minute in any area. No timing is needed. Expected in the log, after a minute: the code: line ends with by runs: N calls a pass, 0 failed since the last line on a kernel 6.10 or later, or a page at a time on an older one; no crash. Optional, on the same machine: one start with HOS_CODE_WARM_COPY=1, expecting a page at a time and a longer pass (a pass ... ms) than without it.

@Beanstalk linux (RADV and NVIDIA) and the Steam Deck, this PR's head: start the game and play a minute in any area. No timing is needed. Expected in the log, after a minute: the `code:` line ends with `by runs: N calls a pass, 0 failed since the last line` on a kernel 6.10 or later, or `a page at a time` on an older one; no crash. Optional, on the same machine: one start with `HOS_CODE_WARM_COPY=1`, expecting `a page at a time` and a longer pass (`a pass ... ms`) than without it.
Author
Member
@review
Member

Possibly related, for context:

  • PR #2893 perf(host): keep the game's executable pages warm under memory pressure (HOS_CODE_WARM) — Introduced the Linux code-warming pass this optimizes
  • PR #2916 fix(host): the code warm pass finds the game's text on btrfs, by the device /proc/self/maps shows for it — Earlier fix in the same code-warm implementation
Possibly related, for context: - PR #2893 perf(host): keep the game's executable pages warm under memory pressure (HOS_CODE_WARM) — Introduced the Linux code-warming pass this optimizes - PR #2916 fix(host): the code warm pass finds the game's text on btrfs, by the device /proc/self/maps shows for it — Earlier fix in the same code-warm implementation
Member

Beanstalk test farm · ⚠️ couldn't be judged on linux+radv, linux+nvidia, steamdeck

Commit a3d0abd · approved by klimovich008 (reviewed) · dashboard

⚠️ Note: The log check cannot choose the expected branch by kernel version or ensure that the matching line was emitted after the minute; it accepts either branch anywhere in the run log.
⚠️ Note: The plan does not measure the claimed reduction in code-warm thread CPU time or pass duration, and does not run the optional copy-switch comparison.

Summary, written by AI (gpt-6.1-terra) from the numbers below:

The change could not be judged on Linux RADV, Linux NVIDIA or Steam Deck. All 5 reports hit the same baseline setup error: main’s tools.lock lists SDL URLs that do not match Longshot’s store, so no game scenarios ran. No timing comparison was planned.

Done (started 15:23 UTC, last report 15:23 UTC). Comment @Beanstalk to run it again.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
linux+radv ⚠️ couldn't be judged 2 1 2 — — none
linux+nvidia ⚠️ couldn't be judged 1 1 — — none
steamdeck ⚠️ couldn't be judged 2 1 2 — — none

Couldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.

  • linux+radv, report 1: main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's
  • linux+radv, report 2: main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's
  • linux+nvidia, report 1: main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's
  • steamdeck, report 1: main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's
  • steamdeck, report 2: main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's
What was tested

What will be tested · AI plan (gpt-6.1-terra)

On Linux RADV, Linux NVIDIA and Steam Deck, the plan starts the game and spends at least a minute in Hyrule Field. It checks for a code-warm log line reporting either zero failed run calls or page-at-a-time operation, and fails on a crash or a missing matching line. No timing comparison is made; main also runs because the farm uses it as the baseline.

  • Where: linux+radv (1-2 reports), linux+nvidia (1-2 reports), steamdeck (1-2 reports).
  • field-code-warm: from the repository's save castle-gate (switches HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720), then teleport to Hyrule Field; 1 run on each side.
  • Measured: crashes, the game's log.
  • The PR fails if: it crashes; or expected log lines missing is above 0.
  • Time: about 13 min of game runs per tester (2 game starts), plus the two builds.
Measurements on `linux+radv`, for the PR description

Verdict: could not be judged on linux+radv (2 reports).

Hardware: 1: linux+amd+radv+igpu AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99 AMD Ryzen Z2 Extreme, 32 GB RAM; 2: linux+amd+radv+igpu AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8 AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM
Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Nothing was measured: no metric came back.

Flags and settings

None: the plan varied no setting, switch or build option.

As Markdown for the PR description:

## Measurements

**Verdict:** could not be judged on linux+radv (2 reports).

Hardware: 1: linux+amd+radv+igpu `AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99` `AMD Ryzen Z2 Extreme, 32 GB RAM`; 2: linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM`  
Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

Nothing was measured: no metric came back.

**Flags and settings**

None: the plan varied no setting, switch or build option.
Measurements on `linux+nvidia`, for the PR description

Verdict: could not be judged on linux+nvidia (1 report).

Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 5070, 620.73.4 AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM
Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Nothing was measured: no metric came back.

Flags and settings

None: the plan varied no setting, switch or build option.

As Markdown for the PR description:

## Measurements

**Verdict:** could not be judged on linux+nvidia (1 report).

Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.73.4` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM`  
Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 1 report  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

Nothing was measured: no metric came back.

**Flags and settings**

None: the plan varied no setting, switch or build option.
Measurements on `steamdeck`, for the PR description

Verdict: could not be judged on steamdeck (2 reports).

Hardware: 1: linux+amd+radv+igpu+handheld AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99 AMD Custom APU 0932, 16 GB RAM; 2: linux+amd+radv+igpu+handheld AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99 AMD Custom APU 0405, 16 GB RAM
Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Nothing was measured: no metric came back.

Flags and settings

None: the plan varied no setting, switch or build option.

As Markdown for the PR description:

## Measurements

**Verdict:** could not be judged on steamdeck (2 reports).

Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0932, 16 GB RAM`; 2: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 16 GB RAM`  
Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

Nothing was measured: no metric came back.

**Flags and settings**

None: the plan varied no setting, switch or build option.
The testers' hardware
Target Report Ran on
linux+radv 1 linux+amd+radv+igpu AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99 AMD Ryzen Z2 Extreme, 32 GB RAM
linux+radv 2 linux+amd+radv+igpu AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8 AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM
linux+nvidia 1 linux+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 5070, 620.73.4 AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM
steamdeck 1 linux+amd+radv+igpu+handheld AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99 AMD Custom APU 0932, 16 GB RAM
steamdeck 2 linux+amd+radv+igpu+handheld AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99 AMD Custom APU 0405, 16 GB RAM
<!-- beanstalk:sticky --> ### Beanstalk test farm · ⚠️ couldn't be judged on linux+radv, linux+nvidia, steamdeck Commit `a3d0abd` · approved by klimovich008 (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/3087) ⚠️ **Note:** The log check cannot choose the expected branch by kernel version or ensure that the matching line was emitted after the minute; it accepts either branch anywhere in the run log. ⚠️ **Note:** The plan does not measure the claimed reduction in code-warm thread CPU time or pass duration, and does not run the optional copy-switch comparison. > **Summary**, written by AI (`gpt-6.1-terra`) from the numbers below: > > The change could not be judged on Linux RADV, Linux NVIDIA or Steam Deck. All 5 reports hit the same baseline setup error: main’s tools.lock lists SDL URLs that do not match Longshot’s store, so no game scenarios ran. No timing comparison was planned. Done (started 15:23 UTC, last report 15:23 UTC). Comment `@Beanstalk` to run it again. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `linux+radv` | ⚠️ couldn't be judged | 2 [1](https://beanstalk.magicbean.dev/reports/rp_748858ef3906a579) [2](https://beanstalk.magicbean.dev/reports/rp_a232469e07824f20) | — | — | none | | `linux+nvidia` | ⚠️ couldn't be judged | 1 [1](https://beanstalk.magicbean.dev/reports/rp_aece3f353823df30) | — | — | none | | `steamdeck` | ⚠️ couldn't be judged | 2 [1](https://beanstalk.magicbean.dev/reports/rp_f1c2b233facc1974) [2](https://beanstalk.magicbean.dev/reports/rp_529517e59e79ba10) | — | — | none | **Couldn't be judged**: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own. - `linux+radv`, [report 1](https://beanstalk.magicbean.dev/reports/rp_748858ef3906a579): `main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's` - `linux+radv`, [report 2](https://beanstalk.magicbean.dev/reports/rp_a232469e07824f20): `main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's` - `linux+nvidia`, [report 1](https://beanstalk.magicbean.dev/reports/rp_aece3f353823df30): `main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's` - `steamdeck`, [report 1](https://beanstalk.magicbean.dev/reports/rp_f1c2b233facc1974): `main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's` - `steamdeck`, [report 2](https://beanstalk.magicbean.dev/reports/rp_529517e59e79ba10): `main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store's` <details><summary>What was tested</summary> **What will be tested** · AI plan (`gpt-6.1-terra`) On Linux RADV, Linux NVIDIA and Steam Deck, the plan starts the game and spends at least a minute in Hyrule Field. It checks for a code-warm log line reporting either zero failed run calls or page-at-a-time operation, and fails on a crash or a missing matching line. No timing comparison is made; main also runs because the farm uses it as the baseline. - **Where:** linux+radv (1-2 reports), linux+nvidia (1-2 reports), steamdeck (1-2 reports). - **field-code-warm:** from the repository's save `castle-gate` (switches `HOS_FPS_MAX=30`, `HOS_OUTPUT_RES=1280x720`), then teleport to Hyrule Field; 1 run on each side. - **Measured:** crashes, the game's log. - **The PR fails if:** it crashes; or expected log lines missing is above 0. - **Time:** about 13 min of game runs per tester (2 game starts), plus the two builds. </details> <details><summary>Measurements on `linux+radv`, for the PR description</summary> **Verdict:** could not be judged on linux+radv (2 reports). Hardware: 1: linux+amd+radv+igpu `AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99` `AMD Ryzen Z2 Extreme, 32 GB RAM`; 2: linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM` Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. As Markdown for the PR description: ```markdown ## Measurements **Verdict:** could not be judged on linux+radv (2 reports). Hardware: 1: linux+amd+radv+igpu `AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99` `AMD Ryzen Z2 Extreme, 32 GB RAM`; 2: linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM` Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. ``` </details> <details><summary>Measurements on `linux+nvidia`, for the PR description</summary> **Verdict:** could not be judged on linux+nvidia (1 report). Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.73.4` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM` Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. As Markdown for the PR description: ```markdown ## Measurements **Verdict:** could not be judged on linux+nvidia (1 report). Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.73.4` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM` Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. ``` </details> <details><summary>Measurements on `steamdeck`, for the PR description</summary> **Verdict:** could not be judged on steamdeck (2 reports). Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0932, 16 GB RAM`; 2: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 16 GB RAM` Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. As Markdown for the PR description: ```markdown ## Measurements **Verdict:** could not be judged on steamdeck (2 reports). Hardware: 1: linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0932, 16 GB RAM`; 2: linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 16 GB RAM` Scene: field-code-warm, from the repository's save castle-gate (HOS_FPS_MAX=30, HOS_OUTPUT_RES=1280x720); each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-code-warm: 1 game start a side; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. **Flags and settings** None: the plan varied no setting, switch or build option. ``` </details> <details><summary>The testers' hardware</summary> | Target | Report | Ran on | | --- | --- | --- | | `linux+radv` | [1](https://beanstalk.magicbean.dev/reports/rp_748858ef3906a579) | linux+amd+radv+igpu `AMD Radeon 890M Graphics (RADV STRIX1), 26.1.99` `AMD Ryzen Z2 Extreme, 32 GB RAM` | | `linux+radv` | [2](https://beanstalk.magicbean.dev/reports/rp_a232469e07824f20) | linux+amd+radv+igpu `AMD Radeon 760M Graphics (RADV PHOENIX), 26.0.8` `AMD Ryzen 5 230 w/ Radeon 760M Graphics, 16 GB RAM` | | `linux+nvidia` | [1](https://beanstalk.magicbean.dev/reports/rp_aece3f353823df30) | linux+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 5070, 620.73.4` `AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM` | | `steamdeck` | [1](https://beanstalk.magicbean.dev/reports/rp_f1c2b233facc1974) | linux+amd+radv+igpu+handheld `AMD Custom GPU 0932 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0932, 16 GB RAM` | | `steamdeck` | [2](https://beanstalk.magicbean.dev/reports/rp_529517e59e79ba10) | linux+amd+radv+igpu+handheld `AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99` `AMD Custom APU 0405, 16 GB RAM` | </details>
BeanBot left a comment

Recommendation: Approve. The Deck results show a substantial reduction in warm-thread CPU time, but the new memory-warming path still needs the requested Linux hardware runs and a comparison under memory pressure. The fallback test also has a gap that can hide a broken copy path. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.

On Linux 6.10 and later, cached executable pages are touched in runs of up to 64 KB instead of copied one byte per page. This reduces warm-thread work on the tested Deck at the cost of a new kernel-dependent path and fallback logic.

Should fix (1): not blocking, but worth doing before merging.

  • L1 tests/code_warm_pass_test.c:52: The capability check uses the copy implementation under test to decide whether to skip its own assertions. (more on the line) Do: Probe process_vm_readv and /proc/self/mem independently of copy_pages, then require the copy assertions whenever either underlying method works.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 host/code_warm.c:138: Check that the new touch method preserves the original protection against code eviction under sustained memory pressure. (more on the line) Do: Compare main and this head over repeated equivalent memory-pressure game runs, recording code residency, major faults and frame-time tails, including the slow-storage case the warmer addresses.
  • L3 host/code_warm.c:138: The affected Linux RADV and NVIDIA systems still need the in-game runs requested by the author. (more on the line) Do: Complete the requested Linux RADV and NVIDIA game runs on the head, checking the code-warm log and normal play; record the results before merge.

@fix can do L1.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes on the tested Steam Deck: the PR reports 2.7% of one core versus 13.8% on main and a 56.7 ms pass versus 335.1 ms with 750 MB cached. The CPU figures are one run per side; earlier alternating pairs reported 47–58 ms versus 311–348 ms per pass. The measured build predates the current rebase.

Other systems: The change runs only on Linux; Windows and macOS retain the existing stub. Linux kernels before 6.10 use the copy path. The Deck was tested in game, but the requested Linux RADV and NVIDIA runs, kernels 6.10–7.1, 64 KB pages, and filesystems other than ext4 have no reported in-game coverage. Memory-pressure retention and mmap contention remain relevant across Linux systems.

Switches: HOS_CODE_WARM_COPY is added, default off; setting it to 1 selects the prior copy path. Its default is supported by the Deck timing but remains to be checked on the other affected Linux systems. HOS_CODE_WARM remains on by default and its table description is updated.

Reviewed: a3d0abdce6 against 1e782fa4bb: Read AGENTS.md, CONTRIBUTING.md, the PR template, relevant standards, the complete diff, host/code_warm.c, tests/code_warm_pass_test.c, tests/test_code_warm.py, the code-warm header and startup caller, and the commit messages. Read the changed architecture and switch-table entries. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. Other architecture and switch-table entries were skimmed; no recorded runs, translations, or generated files were changed.; nothing run (a code review).

Checked and fine:

  • Failed populate calls fall back per run, and the run size is capped by page count.
  • The new environment switch is read before the warm thread starts.
  • The changed commits record AI assistance; no game-derived or generated files appear in the diff.

Testing: Read-only review; no code, tests, builds, or project scripts were run. The author reports game-free checks and Deck play; Forgejo checks are still running.

Overlaps and merge order: Not checked; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The Deck results show a substantial reduction in warm-thread CPU time, but the new memory-warming path still needs the requested Linux hardware runs and a comparison under memory pressure. The fallback test also has a gap that can hide a broken copy path. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge. On Linux 6.10 and later, cached executable pages are touched in runs of up to 64 KB instead of copied one byte per page. This reduces warm-thread work on the tested Deck at the cost of a new kernel-dependent path and fallback logic. **Should fix (1)**: not blocking, but worth doing before merging. - **L1** `tests/code_warm_pass_test.c:52`: The capability check uses the copy implementation under test to decide whether to skip its own assertions. (more on the line) **Do:** Probe process_vm_readv and /proc/self/mem independently of copy_pages, then require the copy assertions whenever either underlying method works. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `host/code_warm.c:138`: Check that the new touch method preserves the original protection against code eviction under sustained memory pressure. (more on the line) **Do:** Compare main and this head over repeated equivalent memory-pressure game runs, recording code residency, major faults and frame-time tails, including the slow-storage case the warmer addresses. - **L3** `host/code_warm.c:138`: The affected Linux RADV and NVIDIA systems still need the in-game runs requested by the author. (more on the line) **Do:** Complete the requested Linux RADV and NVIDIA game runs on the head, checking the code-warm log and normal play; record the results before merge. `@fix` can do L1. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes on the tested Steam Deck: the PR reports 2.7% of one core versus 13.8% on main and a 56.7 ms pass versus 335.1 ms with 750 MB cached. The CPU figures are one run per side; earlier alternating pairs reported 47–58 ms versus 311–348 ms per pass. The measured build predates the current rebase. **Other systems:** The change runs only on Linux; Windows and macOS retain the existing stub. Linux kernels before 6.10 use the copy path. The Deck was tested in game, but the requested Linux RADV and NVIDIA runs, kernels 6.10–7.1, 64 KB pages, and filesystems other than ext4 have no reported in-game coverage. Memory-pressure retention and mmap contention remain relevant across Linux systems. **Switches:** HOS_CODE_WARM_COPY is added, default off; setting it to 1 selects the prior copy path. Its default is supported by the Deck timing but remains to be checked on the other affected Linux systems. HOS_CODE_WARM remains on by default and its table description is updated. **Reviewed:** a3d0abdce6c2 against 1e782fa4bbbe: Read AGENTS.md, CONTRIBUTING.md, the PR template, relevant standards, the complete diff, host/code_warm.c, tests/code_warm_pass_test.c, tests/test_code_warm.py, the code-warm header and startup caller, and the commit messages. Read the changed architecture and switch-table entries. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. Other architecture and switch-table entries were skimmed; no recorded runs, translations, or generated files were changed.; nothing run (a code review). **Checked and fine:** - Failed populate calls fall back per run, and the run size is capped by page count. - The new environment switch is read before the warm thread starts. - The changed commits record AI assistance; no game-derived or generated files appear in the diff. **Testing:** Read-only review; no code, tests, builds, or project scripts were run. The author reports game-free checks and Deck play; Forgejo checks are still running. **Overlaps and merge order:** Not checked; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by klimovich008. Nothing was run; a maintainer decides.</sub>
@ -80,0 +135,4 @@
k++;
continue;
}
uint64_t e = k;
Member

L2 (should fix): Check that the new touch method preserves the original protection against code eviction under sustained memory pressure.

When: When executable pages compete with game memory, a difference in reclaim behavior or readahead can change guest major faults and frame stalls even if pagemap and smaps show pages touched immediately after a pass.

Do: Compare main and this head over repeated equivalent memory-pressure game runs, recording code residency, major faults and frame-time tails, including the slow-storage case the warmer addresses.

**L2** (should fix): Check that the new touch method preserves the original protection against code eviction under sustained memory pressure. *When:* When executable pages compete with game memory, a difference in reclaim behavior or readahead can change guest major faults and frame stalls even if pagemap and smaps show pages touched immediately after a pass. **Do:** Compare main and this head over repeated equivalent memory-pressure game runs, recording code residency, major faults and frame-time tails, including the slow-storage case the warmer addresses.
Member

L3 (should fix): The affected Linux RADV and NVIDIA systems still need the in-game runs requested by the author.

When: The default changes the kernel calls made by the warm thread on Linux 6.10 and later, while the reported in-game result covers only the Deck configuration.

Do: Complete the requested Linux RADV and NVIDIA game runs on the head, checking the code-warm log and normal play; record the results before merge.

**L3** (should fix): The affected Linux RADV and NVIDIA systems still need the in-game runs requested by the author. *When:* The default changes the kernel calls made by the warm thread on Linux 6.10 and later, while the reported in-game result covers only the Deck configuration. **Do:** Complete the requested Linux RADV and NVIDIA game runs on the head, checking the code-warm log and normal play; record the results before merge.
@ -28,0 +49,4 @@
madvise_works, whether madvise can set up the cases' pages (MADV_DONTNEED). */
static int copy_reads_here(long page, int memfd) {
char *p = mmap(NULL, (size_t)page, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (p == MAP_FAILED) return 0;
Member

L1 (should fix): The capability check uses the copy implementation under test to decide whether to skip its own assertions.

When: If copy_pages regresses to return zero for every page, copy_reads_here reports that the environment cannot copy, the copy cases are skipped, and the sandbox child also skips. On a supported kernel the run-path checks can still pass, leaving the broken fallback undetected.

Do: Probe process_vm_readv and /proc/self/mem independently of copy_pages, then require the copy assertions whenever either underlying method works.

**L1** (should fix): The capability check uses the copy implementation under test to decide whether to skip its own assertions. *When:* If copy_pages regresses to return zero for every page, copy_reads_here reports that the environment cannot copy, the copy cases are skipped, and the sandbox child also skips. On a supported kernel the run-path checks can still pass, leaving the broken fallback undetected. **Do:** Probe process_vm_readv and /proc/self/mem independently of copy_pages, then require the copy assertions whenever either underlying method works.
HumanBean changed title from WIP: perf(host): on Linux 6.10+ the code warm touches cached code a run at a time, not a page at a time to perf(host): on Linux 6.10+ the code warm touches cached code a run at a time, not a page at a time 2026-12-03 15:26:38 +00:00
HumanBean deleted branch perf/code-warm-populate 2026-12-03 15:26:42 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!3087
No description provided.