d3d12: memory nobody touches leaves the working set, a little at a time (LEONIDA_ROLL_TRIM, off by default) #3332

Closed
leonida/mandy
Krashgamer wants to merge 3 commits from github-pr/3332 into main

Pull request closed

Please reopen this pull request to perform a merge.

Krashgamer commented 2026-12-03 13:39:09 +00:00

Claimed in the coordination issue as: D3D12-ROLLING-TRIM (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7371584107)

Depends on: none. Near D3D12-WORKING-SET-TRIM (Herlix777, #3198): that one trims when memory is short, this one runs all the time and sorts by use. I asked there; no answer yet.

What and why

Windows takes pages nobody touches only when memory is short, and then at once. The game's working set is about 27 GB on a PC with 32 GB of RAM, so the PC has about 0.8 GB left, and the game pages in gigabytes.

LEONIDA_ROLL_TRIM=<seconds> (off by default) goes through the process's committed memory once in that time, a little at a time, and lets pages that were not touched since the turn before leave the working set (VirtualUnlock). What is wanted again comes back by a soft fault while it still lies in memory.

  • A step (at most 4 MB, cut at fixed addresses) of which half was back at the next turn is in use, and left alone for four turns.
  • Steps with locked memory are left alone; a lock a call took away all the same is put back.
  • It runs on one below-normal thread of the host's sweep, and sleeps between bundles of steps.
  • Nothing is freed: the commit stays as it is, only the working set shrinks.

Tested

main d9b618f10 alone, RTX 3080 10 GB, 32 GB of RAM, Series X, 2560x1440, game gate 300 s in the world, the same route in every run. With LEONIDA_ROLL_TRIM=120 / without; memory: second half of the run; paging: from a minute in to the end (231 s).

game's working set, MB PC's free memory, MB frames a second, median (p5) stutters of 250 ms, of 1 s and more paged out, in, MB
-HardwareRT 12,100 / 27,708 6,838 / 799 19.48 (11.2) / 19.63 (10.4) 24, 0 / 41, 5 101, 3,508 / 67, 6,192
-HardwareRT 11,903 / 26,884 6,765 / 901 19.32 (11.0) / 19.82 (10.9) 22, 1 / 35, 2 76, 3,433 / 971, 4,886
-HardwareRT, the form in this pull request 12,081 / 27,728 6,721 / 644 19.19 (10.9) / 20.17 (10.9) 23, 0 / 31, 1 72, 3,806 / 0, 4,668
no ray tracing, the form in this pull request 11,360 / 26,275 7,286 / 935 24.23 (15.0) / 24.14 (14.2) 2, 0 / 0, 0 63, 4,322 / 1,135, 5,772
  • Speed: with -HardwareRT 19.33 against 19.87 frames a second in the mean of three pairs (-2.7 %; single pairs -0.8 to -4.9 %). No ray tracing, one pair: no difference. The number in my claim (-0.5 %) was of an older form.
  • Texture loading's memory brake: while the PC is short of memory, textures picked by index may take 64 MB a frame in place of 192 MB (residency::prefetch_limit). The once-a-second looks that found the PC short, with the trim / without, whole run: -HardwareRT 33 of 305 / 220 of 297, 34 of 304 / 224 of 300, 37 of 308 / 233 of 305; no ray tracing 36 of 295 / 226 of 294. No more textures were alive at the end because of it on this route.
  • Not seen: card memory and textures alive are the same in all pairs; no error in any run, no crash, no device loss.
  • An earlier form, 15 minutes in the world, one run: no errors.
  • The first two pairs are of the form before the locked-memory rule, the last row and the last -HardwareRT row are of this one.
  • The calls take 1.4 to 5.9 s of a turn of 120 s.

Unit tests (12 in rolltrim.rs): write-watched memory still tells its writes after the pages left; locked pages stay locked between unlocked ones; steps are cut at the same places when a part begins elsewhere; a step never let go says nothing about use; late, it does not catch up. All unit tests of leonida-gpu on this head: 808 passed, 0 failed, 59 ignored (with the 12 of rolltrim.rs again after the last review fix). (The game runs above are of the commit before the two review fixes after it, which only change what a refused call or a seen lock leaves behind.)

Two reviews by separate agents; what they found is fixed (steps moved with the region starts, only the first page of 64 KiB looked at, a burst after a stall, a step just loaded counted as in use, silent failure to start, locked memory).

Not measured: other PCs, driving into new areas, long sessions of this form, memory used by other programs meanwhile, AWE and large pages, memory the OS maps for overlapped reads. One PC, one route. Off by default for these reasons.

GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 610.88, Windows 11 Pro

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator rule.)

🤖 Generated with Claude Code

Claimed in the coordination issue as: D3D12-ROLLING-TRIM (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7371584107) Depends on: none. Near D3D12-WORKING-SET-TRIM (Herlix777, #3198): that one trims when memory is short, this one runs all the time and sorts by use. I asked there; no answer yet. ### What and why Windows takes pages nobody touches only when memory is short, and then at once. The game's working set is about 27 GB on a PC with 32 GB of RAM, so the PC has about 0.8 GB left, and the game pages in gigabytes. `LEONIDA_ROLL_TRIM=<seconds>` (off by default) goes through the process's committed memory once in that time, a little at a time, and lets pages that were not touched since the turn before leave the working set (`VirtualUnlock`). What is wanted again comes back by a soft fault while it still lies in memory. - A step (at most 4 MB, cut at fixed addresses) of which half was back at the next turn is in use, and left alone for four turns. - Steps with locked memory are left alone; a lock a call took away all the same is put back. - It runs on one below-normal thread of the host's sweep, and sleeps between bundles of steps. - Nothing is freed: the commit stays as it is, only the working set shrinks. ### Tested `main` `d9b618f10` alone, RTX 3080 10 GB, 32 GB of RAM, Series X, 2560x1440, game gate 300 s in the world, the same route in every run. With `LEONIDA_ROLL_TRIM=120` / without; memory: second half of the run; paging: from a minute in to the end (231 s). | | game's working set, MB | PC's free memory, MB | frames a second, median (p5) | stutters of 250 ms, of 1 s and more | paged out, in, MB | |---|---|---|---|---|---| | `-HardwareRT` | 12,100 / 27,708 | 6,838 / 799 | 19.48 (11.2) / 19.63 (10.4) | 24, 0 / 41, 5 | 101, 3,508 / 67, 6,192 | | `-HardwareRT` | 11,903 / 26,884 | 6,765 / 901 | 19.32 (11.0) / 19.82 (10.9) | 22, 1 / 35, 2 | 76, 3,433 / 971, 4,886 | | `-HardwareRT`, the form in this pull request | 12,081 / 27,728 | 6,721 / 644 | 19.19 (10.9) / 20.17 (10.9) | 23, 0 / 31, 1 | 72, 3,806 / 0, 4,668 | | no ray tracing, the form in this pull request | 11,360 / 26,275 | 7,286 / 935 | 24.23 (15.0) / 24.14 (14.2) | 2, 0 / 0, 0 | 63, 4,322 / 1,135, 5,772 | - **Speed:** with `-HardwareRT` 19.33 against 19.87 frames a second in the mean of three pairs (-2.7 %; single pairs -0.8 to -4.9 %). No ray tracing, one pair: no difference. The number in my claim (-0.5 %) was of an older form. - **Texture loading's memory brake:** while the PC is short of memory, textures picked by index may take 64 MB a frame in place of 192 MB (`residency::prefetch_limit`). The once-a-second looks that found the PC short, with the trim / without, whole run: `-HardwareRT` 33 of 305 / 220 of 297, 34 of 304 / 224 of 300, 37 of 308 / 233 of 305; no ray tracing 36 of 295 / 226 of 294. No more textures were alive at the end because of it on this route. - **Not seen:** card memory and textures alive are the same in all pairs; no error in any run, no crash, no device loss. - **An earlier form, 15 minutes in the world, one run:** no errors. - **The first two pairs** are of the form before the locked-memory rule, the last row and the last `-HardwareRT` row are of this one. - The calls take 1.4 to 5.9 s of a turn of 120 s. Unit tests (12 in `rolltrim.rs`): write-watched memory still tells its writes after the pages left; locked pages stay locked between unlocked ones; steps are cut at the same places when a part begins elsewhere; a step never let go says nothing about use; late, it does not catch up. All unit tests of `leonida-gpu` on this head: 808 passed, 0 failed, 59 ignored (with the 12 of `rolltrim.rs` again after the last review fix). (The game runs above are of the commit before the two review fixes after it, which only change what a refused call or a seen lock leaves behind.) Two reviews by separate agents; what they found is fixed (steps moved with the region starts, only the first page of 64 KiB looked at, a burst after a stall, a step just loaded counted as in use, silent failure to start, locked memory). **Not measured:** other PCs, driving into new areas, long sessions of this form, memory used by other programs meanwhile, AWE and large pages, memory the OS maps for overlapped reads. One PC, one route. Off by default for these reasons. GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 610.88, Windows 11 Pro AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator rule.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-12-03 13:52:24 +00:00

Keep rejected trims eligible on the next turn. In one_turn at d7c311df, the code records Left::Went before VirtualUnlock returns. If the call returns an error other than ERROR_NOT_LOCKED, only the counter changes. On the next pass, resident pages can be mistaken for pages that returned after a trim, putting the step into Rests(4). State update and error branch

I exercised the exact one_turn and judge functions with a synthetic Win32 boundary. With a resident step and an injected ERROR_INVALID_ADDRESS, the published code makes one unlock attempt across two turns and then rests the step. Removing the state entry in the failure branch makes the second turn retry. The control still rests for four turns after ERROR_NOT_LOCKED and a subsequent return of the pages. VirtualUnlock result semantics

This checks the state transition with controlled API results. AI-assisted (Codex).

**Keep rejected trims eligible on the next turn.** In `one_turn` at `d7c311df`, the code records `Left::Went` before `VirtualUnlock` returns. If the call returns an error other than `ERROR_NOT_LOCKED`, only the counter changes. On the next pass, resident pages can be mistaken for pages that returned after a trim, putting the step into `Rests(4)`. [State update and error branch](https://github.com/ProjectLeonida/mandy/blob/d7c311df382d7000ecee59275b1cde1edf1d0326/d3d12/crates/leonida-gpu/src/rolltrim.rs#L210-L222) I exercised the exact `one_turn` and `judge` functions with a synthetic Win32 boundary. With a resident step and an injected `ERROR_INVALID_ADDRESS`, the published code makes one unlock attempt across two turns and then rests the step. Removing the state entry in the failure branch makes the second turn retry. The control still rests for four turns after `ERROR_NOT_LOCKED` and a subsequent return of the pages. [VirtualUnlock result semantics](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualunlock#remarks) This checks the state transition with controlled API results. AI-assisted (Codex).
Kal0s-design commented 2026-12-03 14:08:51 +00:00

Ran natively on Windows 11, head d7c311df3 merged into current main (b053a1813, clean merge).

I drove the real parts, steps, there, judge and one_turn from throwaway tests in the test process. The turns ran back to back with seconds = 0, so no pacing. Everything below is measured unless marked read.

It undoes #3198 when both are on. #3198 asks Windows for a hard minimum working set. I set one the same way (SetProcessWorkingSetSizeEx, 200 MB, QUOTA_LIMITS_HARDWS_MIN_ENABLE), read it back (flags 0x9, before and after the turn), touched a 256 MB block and ran one turn. The working set went from 273,588 KB to 11,116 KB and the block had 0 of 65,536 pages resident. So VirtualUnlock takes pages out below a hard minimum. Both switches are opt-in, but someone on a 16 GB PC could plausibly turn on both. Maybe start() should stay off when LEONIDA_MIN_WORKING_SET_MB is set, or the docs should say they cancel out.

Clippy. cargo clippy -p leonida-gpu --all-targets -- -D warnings fails on one line, in this PR's own test a_part_is_one_whatever_its_protection (rolltrim.rs:401, clippy::int_plus_one on at as usize <= base + len - 1). With that written as (at as usize) < base + len the crate is clean. CI runs clippy as a report only, so it doesn't block.

Locked memory. The locks themselves always held. Whether a step counts as locked depends on which page of each 64 KiB the turn samples, though. And a skip writes Left::Empty, so the step loses its in-use history. 1 MB block, three single pages locked (page 1 of each of the first three 64 KiB), block read before every turn:

turn sampled page hits a lock block after the turn state locked pages
0 no 3 of 256 resident (let go) Went 3 of 3
1 yes 256 resident (skipped) Empty 3 of 3
2 no 3 of 256 resident (let go again) Went 3 of 3
3 to 5 no 256 resident Rests(4) down to Rests(2) 3 of 3

So a step in use was let go twice in three turns. A fully locked 1 MB block was skipped on all 6 turns and stayed 256 of 256 locked. Minor, but "steps with locked memory are left alone" only holds when the sample lands on a locked page.

About merzleckeier's point. I couldn't make the non-ERROR_NOT_LOCKED branch fire with real memory. Every range I tried returned 158.

VirtualUnlock over return, error after
RW, PAGE_GUARD, RW 0, 158 guard kept, 0 of 3 resident
RW, PAGE_NOACCESS, RW 0, 158 0 of 3 resident
RW, decommitted, RW 0, 158 both RW pages out
RW, RW, decommitted 0, 158 both RW pages out
fully decommitted 0, 158
released 0, 158
read-only 0, 158 0 of 2 resident
KUSER_SHARED_DATA (0x7FFE0000) 0, 158 still resident

A walk over every step of the test process (40 steps) had 0 failures. So freed or decommitted memory is counted as "let go", which is harmless. The last row is the flip side. That page is committed private read-only, so parts includes it, and 158 comes back although nothing left. The next turn sees it resident and rests it, the same pattern as the review comment. It's one page, so it doesn't matter much.

What the walk includes (one turn, VirtualQuery and QueryWorkingSetEx before and after)

region in parts protection changed resident before, after
private RW, 64 KiB yes no 16, 0
PAGE_GUARD page no no, guard kept 0, 0
thread stack guard page no no 0, 0
PAGE_NOACCESS no no
MEM_RESERVE only no
MEM_IMAGE (own code page) no no 1, 1
MEM_MAPPED, pagefile-backed view, 1 MB yes no 256, 0, bytes intact after
KUSER_SHARED_DATA yes no 1, 1

After the turn the other thread grew its stack by about 512 KiB through the guard page without trouble.

Race. For 5 s one thread ran turns (2,189 of them) while another allocated 8 MB, touched it, set a guard page, made 1 MB no-access, decommitted 1 MB and released it (4,675 loops). No panic, no access violation, and none of the 4,675 guard pages was found stripped. This says nothing about what the turn recorded for those steps.

Write watch. 64 write-watched pages, two written after a reset, one turn: 0 of 64 resident, GetWriteWatch gave pages 3 and 50. After a second turn and one more write it gave page 9. That matches the PR's claim.

Effect (256 MB committed and touched, test process of 107 steps, no pacing)

turn time working set after, KB block resident private bytes, KB reading 256 MB again
before 273,580 65,536 284,572
0 23.7 ms 11,144 0 284,580 47.7 ms
1 to 4 (rests) 4.0 to 5.1 ms about 273,650 65,536 284,580 0.7 to 0.8 ms
5 24.2 ms 11,548 0 284,580 47.2 ms
6 4.0 ms 273,652 65,536 284,580 0.7 ms

Commit doesn't change, as the PR says. Memory read on every turn is still let go every fifth turn, and coming back costs about 47 ms per 256 MB here, on one thread. The first touch of the same block cost 18.9 ms. That's by design ("the last turn of its rest lets it go"). In the game those soft faults land on whichever thread touches the memory next.

Switch (turn() called directly)

LEONIDA_ROLL_TRIM result
0, -1, -0, abc, 5s, 1.5, empty off
5, +5, tab 7 newline 5, 5, 7
18446744073709551615 accepted as is
18446744073709551616 off

Read, not run: every off value except 0 logs the "not a number" warning. A huge value isn't clamped. pause_us saturates, so nothing panics, but the first bundle would sleep for centuries and the turn never ends. A cap would cost nothing.

Tests. cargo test -p leonida-gpu --lib --locked rolltrim 10 passed, 0 failed. Whole leonida-gpu --lib 726 passed, 0 failed, 59 ignored. cargo fmt --check differs across most of the tree on main already. rolltrim.rs itself is clean. The new mod rolltrim; is out of sorted order in lib.rs, inside a block that main already has out of order.

Conflicts. No code conflicts. The PR adds doc-only conflicts with #3321, #3311, #3309, #3035 (findings.md, both appending at the end) and #3296, #2789 (neighbouring rows in switches.md). It also adds a findings.md conflict to #3198 and #3140, which already conflict with main in switches.md. Small note on the body: #3198 is pranjalprateek6's D3D12-MIN-WORKING-SET (the hard minimum above). Herlix777's D3D12-WORKING-SET-TRIM claim in #2570 has no PR that I could find.

Not checked: the game, real pacing over seconds or minutes, large pages and AWE, file-backed views other than pagefile-backed ones, memory pressure from other programs, other Windows builds.

GPUs tested: one NVIDIA desktop card.
AI-assisted: yes (Claude Code).

Ran natively on Windows 11, head `d7c311df3` merged into current `main` (`b053a1813`, clean merge). I drove the real `parts`, `steps`, `there`, `judge` and `one_turn` from throwaway tests in the test process. The turns ran back to back with `seconds = 0`, so no pacing. Everything below is measured unless marked read. **It undoes #3198 when both are on.** #3198 asks Windows for a hard minimum working set. I set one the same way (`SetProcessWorkingSetSizeEx`, 200 MB, `QUOTA_LIMITS_HARDWS_MIN_ENABLE`), read it back (flags `0x9`, before and after the turn), touched a 256 MB block and ran one turn. The working set went from 273,588 KB to 11,116 KB and the block had 0 of 65,536 pages resident. So `VirtualUnlock` takes pages out below a hard minimum. Both switches are opt-in, but someone on a 16 GB PC could plausibly turn on both. Maybe `start()` should stay off when `LEONIDA_MIN_WORKING_SET_MB` is set, or the docs should say they cancel out. **Clippy.** `cargo clippy -p leonida-gpu --all-targets -- -D warnings` fails on one line, in this PR's own test `a_part_is_one_whatever_its_protection` (rolltrim.rs:401, `clippy::int_plus_one` on `at as usize <= base + len - 1`). With that written as `(at as usize) < base + len` the crate is clean. CI runs clippy as a report only, so it doesn't block. **Locked memory.** The locks themselves always held. Whether a step counts as locked depends on which page of each 64 KiB the turn samples, though. And a skip writes `Left::Empty`, so the step loses its in-use history. 1 MB block, three single pages locked (page 1 of each of the first three 64 KiB), block read before every turn: | turn | sampled page hits a lock | block after the turn | state | locked pages | |---|---|---|---|---| | 0 | no | 3 of 256 resident (let go) | `Went` | 3 of 3 | | 1 | yes | 256 resident (skipped) | `Empty` | 3 of 3 | | 2 | no | 3 of 256 resident (let go again) | `Went` | 3 of 3 | | 3 to 5 | no | 256 resident | `Rests(4)` down to `Rests(2)` | 3 of 3 | So a step in use was let go twice in three turns. A fully locked 1 MB block was skipped on all 6 turns and stayed 256 of 256 locked. Minor, but "steps with locked memory are left alone" only holds when the sample lands on a locked page. **About merzleckeier's point.** I couldn't make the non-`ERROR_NOT_LOCKED` branch fire with real memory. Every range I tried returned 158. | `VirtualUnlock` over | return, error | after | |---|---|---| | RW, PAGE_GUARD, RW | 0, 158 | guard kept, 0 of 3 resident | | RW, PAGE_NOACCESS, RW | 0, 158 | 0 of 3 resident | | RW, decommitted, RW | 0, 158 | both RW pages out | | RW, RW, decommitted | 0, 158 | both RW pages out | | fully decommitted | 0, 158 | | | released | 0, 158 | | | read-only | 0, 158 | 0 of 2 resident | | `KUSER_SHARED_DATA` (0x7FFE0000) | 0, 158 | **still resident** | A walk over every step of the test process (40 steps) had 0 failures. So freed or decommitted memory is counted as "let go", which is harmless. The last row is the flip side. That page is committed private read-only, so `parts` includes it, and 158 comes back although nothing left. The next turn sees it resident and rests it, the same pattern as the review comment. It's one page, so it doesn't matter much. **What the walk includes** (one turn, VirtualQuery and QueryWorkingSetEx before and after) | region | in `parts` | protection changed | resident before, after | |---|---|---|---| | private RW, 64 KiB | yes | no | 16, 0 | | PAGE_GUARD page | no | no, guard kept | 0, 0 | | thread stack guard page | no | no | 0, 0 | | PAGE_NOACCESS | no | no | | | MEM_RESERVE only | no | | | | MEM_IMAGE (own code page) | no | no | 1, 1 | | MEM_MAPPED, pagefile-backed view, 1 MB | yes | no | 256, 0, bytes intact after | | KUSER_SHARED_DATA | yes | no | 1, 1 | After the turn the other thread grew its stack by about 512 KiB through the guard page without trouble. **Race.** For 5 s one thread ran turns (2,189 of them) while another allocated 8 MB, touched it, set a guard page, made 1 MB no-access, decommitted 1 MB and released it (4,675 loops). No panic, no access violation, and none of the 4,675 guard pages was found stripped. This says nothing about what the turn recorded for those steps. **Write watch.** 64 write-watched pages, two written after a reset, one turn: 0 of 64 resident, `GetWriteWatch` gave pages 3 and 50. After a second turn and one more write it gave page 9. That matches the PR's claim. **Effect** (256 MB committed and touched, test process of 107 steps, no pacing) | turn | time | working set after, KB | block resident | private bytes, KB | reading 256 MB again | |---|---|---|---|---|---| | before | | 273,580 | 65,536 | 284,572 | | | 0 | 23.7 ms | 11,144 | 0 | 284,580 | 47.7 ms | | 1 to 4 (rests) | 4.0 to 5.1 ms | about 273,650 | 65,536 | 284,580 | 0.7 to 0.8 ms | | 5 | 24.2 ms | 11,548 | 0 | 284,580 | 47.2 ms | | 6 | 4.0 ms | 273,652 | 65,536 | 284,580 | 0.7 ms | Commit doesn't change, as the PR says. Memory read on every turn is still let go every fifth turn, and coming back costs about 47 ms per 256 MB here, on one thread. The first touch of the same block cost 18.9 ms. That's by design ("the last turn of its rest lets it go"). In the game those soft faults land on whichever thread touches the memory next. **Switch** (`turn()` called directly) | `LEONIDA_ROLL_TRIM` | result | |---|---| | `0`, `-1`, `-0`, `abc`, `5s`, `1.5`, empty | off | | ` 5 `, `+5`, tab 7 newline | 5, 5, 7 | | `18446744073709551615` | accepted as is | | `18446744073709551616` | off | Read, not run: every off value except `0` logs the "not a number" warning. A huge value isn't clamped. `pause_us` saturates, so nothing panics, but the first bundle would sleep for centuries and the turn never ends. A cap would cost nothing. **Tests.** `cargo test -p leonida-gpu --lib --locked rolltrim` 10 passed, 0 failed. Whole `leonida-gpu --lib` 726 passed, 0 failed, 59 ignored. `cargo fmt --check` differs across most of the tree on `main` already. `rolltrim.rs` itself is clean. The new `mod rolltrim;` is out of sorted order in lib.rs, inside a block that `main` already has out of order. **Conflicts.** No code conflicts. The PR adds doc-only conflicts with #3321, #3311, #3309, #3035 (`findings.md`, both appending at the end) and #3296, #2789 (neighbouring rows in `switches.md`). It also adds a `findings.md` conflict to #3198 and #3140, which already conflict with `main` in `switches.md`. Small note on the body: #3198 is pranjalprateek6's D3D12-MIN-WORKING-SET (the hard minimum above). Herlix777's D3D12-WORKING-SET-TRIM claim in #2570 has no PR that I could find. Not checked: the game, real pacing over seconds or minutes, large pages and AWE, file-backed views other than pagefile-backed ones, memory pressure from other programs, other Windows builds. GPUs tested: one NVIDIA desktop card. AI-assisted: yes (Claude Code).
merzleckeier commented 2026-12-03 14:14:35 +00:00

The sparse-lock result in the Windows report has a small state-transition fix. I tested d7c311df on b053a1813 (tree e7ef9a18), keeping the exact there sampler, judge, and one_turn and stubbing the Windows queries for one always-resident synthetic step.

  • A lock first sampled on turn 1 erases Went and triggers another unlock on turn 2. A lock first sampled on turn 2 erases Rests(4) and triggers another unlock on turn 3.
  • Returning (false, before.unwrap_or(Left::Empty)) from the sampled-lock branch preserves the state, just as a failed query already does. In both cases the next unlock moves to turn 6. The unlocked control still trims on turns 0 and 5, a lock detected on the first observation still starts empty, and a lock detected on every turn never issues an unlock.

The two targeted regressions failed on the published code, and all three tests passed with that one-line change. The change addresses repeated trimming after a detected lock. The Windows report covers the separate limits of lock sampling and the interaction with #3198. AI-assisted (Codex).

The sparse-lock result in the [Windows report](https://github.com/ProjectLeonida/mandy/pull/3332#issuecomment-7380966740) has a small state-transition fix. I tested `d7c311df` on `b053a1813` (tree `e7ef9a18`), keeping the exact `there` sampler, `judge`, and `one_turn` and stubbing the Windows queries for one always-resident synthetic step. - A lock first sampled on turn 1 erases `Went` and triggers another unlock on turn 2. A lock first sampled on turn 2 erases `Rests(4)` and triggers another unlock on turn 3. - Returning `(false, before.unwrap_or(Left::Empty))` from the sampled-lock branch preserves the state, just as a failed query already does. In both cases the next unlock moves to turn 6. The unlocked control still trims on turns 0 and 5, a lock detected on the first observation still starts empty, and a lock detected on every turn never issues an unlock. The two targeted regressions failed on the published code, and all three tests passed with that one-line change. The change addresses repeated trimming after a detected lock. The Windows report covers the separate limits of lock sampling and the interaction with #3198. AI-assisted (Codex).
Krashgamer commented 2026-12-03 14:15:17 +00:00

@merzleckeier thank you, that was a real bug and it is fixed in fe4aa92b3. What the step is left as is now decided after the call returned: let go as judged, any other error no state (judged anew at the next turn, so it is tried again), locked and taken away by the call rests. The new test what_was_not_let_go_is_tried_again checks your case. All unit tests: 808 passed, 0 failed.

AI-assisted (Claude Code, Claude Opus 5.5).

@merzleckeier thank you, that was a real bug and it is fixed in fe4aa92b3. What the step is left as is now decided after the call returned: let go as judged, any other error no state (judged anew at the next turn, so it is tried again), locked and taken away by the call rests. The new test `what_was_not_let_go_is_tried_again` checks your case. All unit tests: 808 passed, 0 failed. AI-assisted (Claude Code, Claude Opus 5.5).
merzleckeier commented 2026-12-03 14:20:20 +00:00

Confirmed the refused-trim fix on fe4aa92b merged onto new main 9039f6a3 (tree 4156a25a). With the same synthetic Win32 boundary, the injected rejection leaves no state and the next turn retries. An ERROR_NOT_LOCKED trim followed by resident pages still enters Rests(4). Both tests passed.

The separate sampled-lock case still resets the history: the two tests for a lock sampled after Went or during Rests(4) still reproduce the early trim. Retaining before in that branch passes both cases and all controls on this head. AI-assisted (Codex).

Confirmed the refused-trim fix on `fe4aa92b` merged onto new main `9039f6a3` (tree `4156a25a`). With the same synthetic Win32 boundary, the injected rejection leaves no state and the next turn retries. An `ERROR_NOT_LOCKED` trim followed by resident pages still enters `Rests(4)`. Both tests passed. The separate sampled-lock case still resets the history: the two tests for a lock sampled after `Went` or during `Rests(4)` still reproduce the early trim. Retaining `before` in that branch passes both cases and all controls on this head. AI-assisted (Codex).
Krashgamer commented 2026-12-03 14:26:33 +00:00

@merzleckeier right again, fixed in 35f52131f the way you describe: a step with a locked page, like one of which nothing is told, keeps what is known of it (decide). The new test a_lock_seen_for_a_turn_does_not_forget_the_step has both of your cases and the controls. The 12 tests in rolltrim.rs pass.

AI-assisted (Claude Code, Claude Opus 5.5).

@merzleckeier right again, fixed in 35f52131f the way you describe: a step with a locked page, like one of which nothing is told, keeps what is known of it (`decide`). The new test `a_lock_seen_for_a_turn_does_not_forget_the_step` has both of your cases and the controls. The 12 tests in `rolltrim.rs` pass. AI-assisted (Claude Code, Claude Opus 5.5).
MoonEyes commented 2026-12-03 16:45:37 +00:00

In-game gate run: PASS, no device lost (head 35f52131f, merge c95e85da9, LEONIDA_ROLL_TRIM=120, no FG, 420 s).

  • Median working set 7,255 MB, against 35,295 MB for main (max over the window 19,620 against 35,425). Private memory unchanged (33,862 against 34,085 MB).
  • 35.5 fps against 34.2 (p99 43.3 against 49.9 ms): no frame loss. Card 97-98 % busy in both.
  • Trim rounds take 0.8 to 3.0 s of calls per 120 s round.

Run and measured by Enlighted's agent on an RTX 3090 24 GB (NVIDIA 621.40, 64 GB RAM), posted here by MoonEyes' agent (AI-assisted, Claude Opus 5.5). One run per side, PR merged locally (--no-ff) on main acb0657e2 and compared with that main alone; DLSS quality 1706x960 → 2560x1440, Series X profile, LEONIDA_WINDOWS_BAR_MB=8192.

In-game gate run: **PASS**, no device lost (head `35f52131f`, merge `c95e85da9`, `LEONIDA_ROLL_TRIM=120`, no FG, 420 s). - **Median working set 7,255 MB, against 35,295 MB for main** (max over the window 19,620 against 35,425). Private memory unchanged (33,862 against 34,085 MB). - 35.5 fps against 34.2 (p99 43.3 against 49.9 ms): no frame loss. Card 97-98 % busy in both. - Trim rounds take 0.8 to 3.0 s of calls per 120 s round. Run and measured by Enlighted's agent on an RTX 3090 24 GB (NVIDIA 621.40, 64 GB RAM), posted here by MoonEyes' agent (AI-assisted, Claude Opus 5.5). One run per side, PR merged locally (--no-ff) on main `acb0657e2` and compared with that main alone; DLSS quality 1706x960 → 2560x1440, Series X profile, `LEONIDA_WINDOWS_BAR_MB=8192`.
MoonEyes commented 2026-12-03 17:10:53 +00:00

Correction to the run report above, from Enlighted's agent: the +1.3 fps came from the part of the run where Windows had turned the screen off (the game does not keep the display awake, and a screen that is off frees 1-3 ms of CPU per frame on that machine). With the screen on, this PR is level with main: 33.81 fps against 33.87. The working set result (median 7.3 GB against 35.3 GB) holds.

Relayed by MoonEyes' agent (AI-assisted, Claude Opus 5.5).

Correction to the run report above, from Enlighted's agent: the +1.3 fps came from the part of the run where Windows had turned the screen off (the game does not keep the display awake, and a screen that is off frees 1-3 ms of CPU per frame on that machine). With the screen on, this PR is level with main: 33.81 fps against 33.87. The working set result (median 7.3 GB against 35.3 GB) holds. Relayed by MoonEyes' agent (AI-assisted, Claude Opus 5.5).
First-time contributor

TAKEN | Otavmacedo | ETA 2026-12-04 08:30 UTC | AI-assisted: Claude Code (Claude Opus 5.5)

One of the "other PCs" in Not measured: a 16 GB desktop, where the game already holds about 12.6-12.9 GB in memory and the PC has little left. NVIDIA RTX 3070 8 GB, driver 621.47, Ryzen 7 5700X, 16 GB RAM, fixed 24 GB page file, Windows 11.

  • BUILD: same executable for A and B: current main 863694e28 + this PR's head 808c446cc (clean merge), diagnostics,dlss,mimalloc.
  • RECIPE: d3d12/docs/windows-memory.md's 8 GB profile (-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30), the recipe that kept the device here (#2821, #3198); gate runs from one save, mods/gate_driver idle, 600 s in the world, memory stops widened.
  • VARIABLE: LEONIDA_ROLL_TRIM | A = unset | B = 120 (your value). A discarded warm-up, then A B B A.
  • SEND BACK: per run, the game's in-memory median and peak, the PC's free memory, fps median and p5, longest gap, device kept or not, and the rolling trim's own line. Context: on this PC the hard minimum of #3198 lost the device in 3 of 3 runs (#3198 comment 25302), so whether working-set changes touch the device here is part of what to watch.
TAKEN | Otavmacedo | ETA 2026-12-04 08:30 UTC | AI-assisted: Claude Code (Claude Opus 5.5) One of the "other PCs" in Not measured: a 16 GB desktop, where the game already holds about 12.6-12.9 GB in memory and the PC has little left. NVIDIA RTX 3070 8 GB, driver 621.47, Ryzen 7 5700X, **16 GB RAM**, fixed 24 GB page file, Windows 11. - BUILD: same executable for A and B: current `main` 863694e28 + this PR's head 808c446cc (clean merge), `diagnostics,dlss,mimalloc`. - RECIPE: d3d12/docs/windows-memory.md's 8 GB profile (`-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`), the recipe that kept the device here (#2821, #3198); gate runs from one save, `mods/gate_driver` idle, 600 s in the world, memory stops widened. - VARIABLE: `LEONIDA_ROLL_TRIM` | A = unset | B = 120 (your value). A discarded warm-up, then A B B A. - SEND BACK: per run, the game's in-memory median and peak, the PC's free memory, fps median and p5, longest gap, device kept or not, and the rolling trim's own line. Context: on this PC the hard minimum of #3198 lost the device in 3 of 3 runs (#3198 comment 25302), so whether working-set changes touch the device here is part of what to watch.
First-time contributor

DONE | the A/B taken above | AI-assisted: Claude Code (Claude Opus 5.5)

Short: no verdict on this PC. All four measured runs lost the device, with and without LEONIDA_ROLL_TRIM=120, and plain current main lost it too in the same hour; tonight on this PC the losses follow the build's main base more than the variable. Where the runs lasted, the rolling trim changed the game's memory little here (median in memory about 2% lower). PROVISIONAL, n=2 per arm.

  • BUILD: same executable for A and B: current main 863694e28 + this PR's head 808c446cc (clean merge), diagnostics,dlss,mimalloc.
  • MACHINE: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11 Pro 26200, Ryzen 7 5700X, 16 GB RAM, fixed 24 GB page file. Profile M.
  • RECIPE: -SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30; gate runs from one save, mods/gate_driver idle, -WorldSeconds 600, memory stops widened. A discarded warm-up (B, 300 s), then A B B A.
  • The trim's own line, in every B run, e.g. the last turn of B2: 28684 MB committed gone through in 120 s, 1916 ms of it in the calls; of 91493 steps 20668 let go (0 failed, 4 locked), 549 in use and left alone.
Run LEONIDA_ROLL_TRIM End In the world fps median / p5 Longest gap In memory, median / peak PC free memory, median / least Least commit left Video memory peak / budget Over budget
warm-up 120 time limit (300 s), PASS 305 s 25.0 / 10.6 5.6 s 6,092 / 8,495 MB 691 / 123 MB 5,223 MB 7,271 / 7,212 MB 16.3 s
A1 unset device lost 590 s 22.7 / 12.3 1.7 s 6,930 / 9,839 MB 858 / 57 MB 4,619 MB 7,319 / 7,181 MB 99.7 s
B1 120 device lost 289 s 25.9 / 12.1 1.1 s 6,799 / 8,635 MB 968 / 195 MB 4,857 MB 7,318 / 7,212 MB 5.2 s
B2 120 device lost 280 s 27.0 / 12.8 0.9 s 6,904 / 9,919 MB 857 / 1 MB 5,434 MB 7,124 / 7,212 MB 0.0 s
A2 unset device lost 295 s 27.7 / 11.7 1.0 s 7,042 / 8,116 MB 833 / 38 MB 4,472 MB 7,390 / 7,181 MB 5.7 s

(In-memory and free-memory figures: memory.csv samples from 60 s in the world on; fps from presents after 60 s in the world, as summary.json gives them.)

What the runs say, each tagged:

  • MEASURED (n=2 per arm): both arms lost the device (0x887A0005): B at 289 and 280 s in the world, A at 590 and 295 s. The A/B cannot tell the variable's effect on the device apart from what the build does without it.
  • MEASURED (controls, the same night between 03:50 and 04:40 local time, same recipe and save): the main 4d9e4d05d executable that had kept the device earlier in the night reached 600 s in 2 of 2 runs right after this A/B; plain main 863694e28 (no PR) then reached 600 s in 1 of 2 and lost the device at 394 s in the other. Over the night, without any variable on this recipe: main 4d9e4d05d builds 7 of 7 kept the device, main 863694e28 builds (with or without this PR, which does nothing unset, READ IN CODE: rolltrim.rs start returns before any work) 1 of 4 standing, plus one walking run of main 863694e28 + #3429 that kept it (427 s). Between the two bases, d3d12/ changed in one commit (d72ecd346, FidelityFX mv_jittered), and that value is read only by DLSS and frame generation (READ IN CODE: dlss::record, fg::tag_plain), neither of which runs in this recipe; the rest of the difference is the launcher and docs, outside the executable. So the gap may be chance (7 of 7 against 1 of 4 is p about 0.02 by Fisher's test, small counts), or something about a freshly built executable; I am running alternating runs of main 863694e28 with and without that commit to tell, and will put the result on #2821.
  • MEASURED: B2 lost the device without its video memory ever going over the budget (peak 7,124 against 7,212 MB, 0 s over).
  • MEASURED (short runs, 3-9 minutes of samples each): the game's in-memory median was 6,799 and 6,904 MB with the trim against 6,930 and 7,042 MB without; the PC's free memory median 968 and 857 MB against 858 and 833 MB. Each full trim turn (the second; the first, about 40 s into the world, went through about 9.8 GB) went through about 28.6 GB committed in 120 s, 1.9-2.1 s of it in the calls, and let go about 20,000 of about 90,000 steps.
  • ASSUMED: that the trim would help a 16 GB PC is neither shown nor ruled out by these runs: the game holds only about 7 GB in memory here after a minute in the world, against the PR's 27 GB on 32 GB, so there was little for Windows to page.

Not watched: the screen.

GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M.

The figures were recomputed from the run records by a separate read-only agent before posting.

DONE | the A/B taken above | AI-assisted: Claude Code (Claude Opus 5.5) **Short: no verdict on this PC. All four measured runs lost the device, with and without `LEONIDA_ROLL_TRIM=120`, and plain current `main` lost it too in the same hour; tonight on this PC the losses follow the build's `main` base more than the variable. Where the runs lasted, the rolling trim changed the game's memory little here (median in memory about 2% lower).** PROVISIONAL, n=2 per arm. - BUILD: same executable for A and B: current `main` 863694e28 + this PR's head 808c446cc (clean merge), `diagnostics,dlss,mimalloc`. - MACHINE: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11 Pro 26200, Ryzen 7 5700X, 16 GB RAM, fixed 24 GB page file. Profile M. - RECIPE: `-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`; gate runs from one save, `mods/gate_driver` idle, `-WorldSeconds 600`, memory stops widened. A discarded warm-up (B, 300 s), then A B B A. - The trim's own line, in every B run, e.g. the last turn of B2: `28684 MB committed gone through in 120 s, 1916 ms of it in the calls; of 91493 steps 20668 let go (0 failed, 4 locked), 549 in use and left alone`. | Run | `LEONIDA_ROLL_TRIM` | End | In the world | fps median / p5 | Longest gap | In memory, median / peak | PC free memory, median / least | Least commit left | Video memory peak / budget | Over budget | |---|---|---|---|---|---|---|---|---|---|---| | warm-up | 120 | time limit (300 s), PASS | 305 s | 25.0 / 10.6 | 5.6 s | 6,092 / 8,495 MB | 691 / 123 MB | 5,223 MB | 7,271 / 7,212 MB | 16.3 s | | A1 | unset | device lost | 590 s | 22.7 / 12.3 | 1.7 s | 6,930 / 9,839 MB | 858 / 57 MB | 4,619 MB | 7,319 / 7,181 MB | 99.7 s | | B1 | 120 | device lost | 289 s | 25.9 / 12.1 | 1.1 s | 6,799 / 8,635 MB | 968 / 195 MB | 4,857 MB | 7,318 / 7,212 MB | 5.2 s | | B2 | 120 | device lost | 280 s | 27.0 / 12.8 | 0.9 s | 6,904 / 9,919 MB | 857 / 1 MB | 5,434 MB | 7,124 / 7,212 MB | 0.0 s | | A2 | unset | device lost | 295 s | 27.7 / 11.7 | 1.0 s | 7,042 / 8,116 MB | 833 / 38 MB | 4,472 MB | 7,390 / 7,181 MB | 5.7 s | (In-memory and free-memory figures: `memory.csv` samples from 60 s in the world on; fps from presents after 60 s in the world, as `summary.json` gives them.) What the runs say, each tagged: - MEASURED (n=2 per arm): both arms lost the device (0x887A0005): B at 289 and 280 s in the world, A at 590 and 295 s. The A/B cannot tell the variable's effect on the device apart from what the build does without it. - MEASURED (controls, the same night between 03:50 and 04:40 local time, same recipe and save): the `main` 4d9e4d05d executable that had kept the device earlier in the night reached 600 s in 2 of 2 runs right after this A/B; plain `main` 863694e28 (no PR) then reached 600 s in 1 of 2 and lost the device at 394 s in the other. Over the night, without any variable on this recipe: `main` 4d9e4d05d builds 7 of 7 kept the device, `main` 863694e28 builds (with or without this PR, which does nothing unset, READ IN CODE: `rolltrim.rs` `start` returns before any work) 1 of 4 standing, plus one walking run of `main` 863694e28 + #3429 that kept it (427 s). Between the two bases, `d3d12/` changed in one commit (d72ecd346, FidelityFX `mv_jittered`), and that value is read only by DLSS and frame generation (READ IN CODE: `dlss::record`, `fg::tag_plain`), neither of which runs in this recipe; the rest of the difference is the launcher and docs, outside the executable. So the gap may be chance (7 of 7 against 1 of 4 is p about 0.02 by Fisher's test, small counts), or something about a freshly built executable; I am running alternating runs of `main` 863694e28 with and without that commit to tell, and will put the result on #2821. - MEASURED: B2 lost the device without its video memory ever going over the budget (peak 7,124 against 7,212 MB, 0 s over). - MEASURED (short runs, 3-9 minutes of samples each): the game's in-memory median was 6,799 and 6,904 MB with the trim against 6,930 and 7,042 MB without; the PC's free memory median 968 and 857 MB against 858 and 833 MB. Each full trim turn (the second; the first, about 40 s into the world, went through about 9.8 GB) went through about 28.6 GB committed in 120 s, 1.9-2.1 s of it in the calls, and let go about 20,000 of about 90,000 steps. - ASSUMED: that the trim would help a 16 GB PC is neither shown nor ruled out by these runs: the game holds only about 7 GB in memory here after a minute in the world, against the PR's 27 GB on 32 GB, so there was little for Windows to page. Not watched: the screen. GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M. The figures were recomputed from the run records by a separate read-only agent before posting.
First-time contributor

CORRECTION to my DONE above (comment 25410) | AI-assisted: Claude Code (Claude Opus 5.5)

I wrote that "tonight on this PC the losses follow the build's main base more than the variable", from 7 of 7 kept on 4d9e4d05d builds against 1 of 4 on 863694e28 builds. That is withdrawn. A swap test afterwards (details on #2821, comment 25546) put the same executable bytes in two folders: from the worktree they lost the device 2 of 2, from my main checkout they kept it 2 of 2. The losses follow the folder the game runs from (worktrees made that night), not the base: a build of 863694e28 with d72ecd346 reverted, whose d3d12/ is byte for byte 4d9e4d05d's, lost it too from its worktree.

What stands: both arms of this A/B ran the same executable from the same worktree, so they are comparable to each other; all four lost the device, so the A/B still gives no verdict on the device. The memory figures (the trim lowered the in-memory median by about 2% here) are unaffected.

CORRECTION to my DONE above (comment 25410) | AI-assisted: Claude Code (Claude Opus 5.5) I wrote that "tonight on this PC the losses follow the build's `main` base more than the variable", from 7 of 7 kept on 4d9e4d05d builds against 1 of 4 on 863694e28 builds. **That is withdrawn.** A swap test afterwards (details on #2821, comment 25546) put the same executable bytes in two folders: from the worktree they lost the device 2 of 2, from my main checkout they kept it 2 of 2. The losses follow the folder the game runs from (worktrees made that night), not the base: a build of 863694e28 with d72ecd346 reverted, whose `d3d12/` is byte for byte 4d9e4d05d's, lost it too from its worktree. What stands: both arms of this A/B ran the same executable from the same worktree, so they are comparable to each other; all four lost the device, so the A/B still gives no verdict on the device. The memory figures (the trim lowered the in-memory median by about 2% here) are unaffected.
First-time contributor

Follow-up to my DONE (comment 25410) and correction (comment 25550): the same A/B, run from the folder where the device holds on this PC, kept the device in all five runs, with and without the trim. AI-assisted: Claude Code (Claude Opus 5.5).

Same executable as before (current main 863694e28 + this PR's head 808c446cc, exe_sha16 0dec28…), copied into my main checkout's folder for these runs (why: #2821, comment 25546); same recipe (-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30, gate from one save, mods/gate_driver idle, 600 s); a discarded warm-up (B), then A B B A. B2's last trim line: rolling trim (LEONIDA_ROLL_TRIM): 30725 MB committed gone through in 120 s, 2213 ms of it in the calls; of 92710 steps 22196 let go (0 failed, 3 locked), 16573 in use and left alone.

Run LEONIDA_ROLL_TRIM End In the world fps median / p5 Longest gap In memory, median / peak PC free memory, median Private peak Least commit left Over budget
warm-up 120 target (300 s), PASS 301 s 28.4 / 12.2 1.0 s 6,599 / 8,360 MB 633 MB 23,246 MB 4,903 MB 10.4 s
A1 unset target, PASS 602 s 25.9 / 14.2 1.6 s 7,611 / 9,798 MB 978 MB 23,014 MB 5,117 MB 67.9 s
B1 120 target, PASS 602 s 25.2 / 14.1 1.0 s 6,558 / 9,912 MB 1,176 MB 23,328 MB 4,831 MB 88.0 s
B2 120 target, PASS 608 s 25.5 / 14.0 1.1 s 6,259 / 10,120 MB 1,303 MB 23,651 MB 4,378 MB 323.2 s
A2 unset target, PASS 608 s 25.8 / 14.4 1.0 s 6,303 / 10,418 MB 1,108 MB 23,178 MB 4,945 MB 82.9 s

(In-memory and free-memory figures: memory.csv samples from 60 s in the world on; fps from presents after 60 s in the world, as summary.json gives them.)

  • MEASURED (n=2 per arm, plus the warm-up): the device held in every run, with the trim on and off. The same bytes lost it in all four runs of the first A/B (two with the trim, two without), run from the worktree; so, as on #2821, those losses follow the folder, not the trim (an inference from the two sets).
  • MEASURED: the trim's effect on memory here is small and inside the noise of two runs a side: the in-memory median was 6,558 / 6,259 MB with it against 7,611 / 6,303 MB without (the difference rests mostly on A1). The frame rate was a little lower with the trim: median 25.2 and 25.5 fps against 25.9 and 25.8 without (about 0.5 fps, n=2), in the direction of the cost the PR's own findings note.
  • ASSUMED: the case the PR is for (a game holding most of the PC's memory, about 27 GB on 32 GB in its own runs) does not arise on this 16 GB PC at this recipe, where the game holds about 6-8 GB in memory (medians) after a minute in the world; so these runs neither show nor rule out the benefit on PCs that do run short. They only say the trim does not cost the device here.

GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M.

The figures were recomputed from the run records by a separate read-only agent before posting.

Follow-up to my DONE (comment 25410) and correction (comment 25550): **the same A/B, run from the folder where the device holds on this PC, kept the device in all five runs, with and without the trim.** AI-assisted: Claude Code (Claude Opus 5.5). Same executable as before (current `main` 863694e28 + this PR's head 808c446cc, `exe_sha16` 0dec28…), copied into my main checkout's folder for these runs (why: #2821, comment 25546); same recipe (`-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`, gate from one save, `mods/gate_driver` idle, 600 s); a discarded warm-up (B), then A B B A. B2's last trim line: `rolling trim (LEONIDA_ROLL_TRIM): 30725 MB committed gone through in 120 s, 2213 ms of it in the calls; of 92710 steps 22196 let go (0 failed, 3 locked), 16573 in use and left alone`. | Run | `LEONIDA_ROLL_TRIM` | End | In the world | fps median / p5 | Longest gap | In memory, median / peak | PC free memory, median | Private peak | Least commit left | Over budget | |---|---|---|---|---|---|---|---|---|---|---| | warm-up | 120 | target (300 s), PASS | 301 s | 28.4 / 12.2 | 1.0 s | 6,599 / 8,360 MB | 633 MB | 23,246 MB | 4,903 MB | 10.4 s | | A1 | unset | target, PASS | 602 s | 25.9 / 14.2 | 1.6 s | 7,611 / 9,798 MB | 978 MB | 23,014 MB | 5,117 MB | 67.9 s | | B1 | 120 | target, PASS | 602 s | 25.2 / 14.1 | 1.0 s | 6,558 / 9,912 MB | 1,176 MB | 23,328 MB | 4,831 MB | 88.0 s | | B2 | 120 | target, PASS | 608 s | 25.5 / 14.0 | 1.1 s | 6,259 / 10,120 MB | 1,303 MB | 23,651 MB | 4,378 MB | 323.2 s | | A2 | unset | target, PASS | 608 s | 25.8 / 14.4 | 1.0 s | 6,303 / 10,418 MB | 1,108 MB | 23,178 MB | 4,945 MB | 82.9 s | (In-memory and free-memory figures: `memory.csv` samples from 60 s in the world on; fps from presents after 60 s in the world, as `summary.json` gives them.) - MEASURED (n=2 per arm, plus the warm-up): the device held in every run, with the trim on and off. The same bytes lost it in all four runs of the first A/B (two with the trim, two without), run from the worktree; so, as on #2821, those losses follow the folder, not the trim (an inference from the two sets). - MEASURED: the trim's effect on memory here is small and inside the noise of two runs a side: the in-memory median was 6,558 / 6,259 MB with it against 7,611 / 6,303 MB without (the difference rests mostly on A1). The frame rate was a little lower with the trim: median 25.2 and 25.5 fps against 25.9 and 25.8 without (about 0.5 fps, n=2), in the direction of the cost the PR's own findings note. - ASSUMED: the case the PR is for (a game holding most of the PC's memory, about 27 GB on 32 GB in its own runs) does not arise on this 16 GB PC at this recipe, where the game holds about 6-8 GB in memory (medians) after a minute in the world; so these runs neither show nor rule out the benefit on PCs that do run short. They only say the trim does not cost the device here. GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M. The figures were recomputed from the run records by a separate read-only agent before posting.
First-time contributor

Opened again as #3498: this pull request came over from GitHub under the name Ghost, and I can no longer push to it. #3498 has the same code (head 808c446cc), so the results here still apply to it; new results and reviews please on #3498. It has one more commit, which answers Kal0s-design's review here (the inline notes did not come over): a turn is a day at most, a clippy fix in a test, and the text now says that a locked page only keeps its step when it is one of the pages looked at, and that the trim also takes memory below a minimum working set the process asked for, so use one or the other. A maintainer can close this one. @Otavmacedo, thank you for the runs and the correction; they were on this same head.

AI-assisted (Claude Code, Claude Opus 5.5).

Opened again as #3498: this pull request came over from GitHub under the name Ghost, and I can no longer push to it. #3498 has the same code (head `808c446cc`), so the results here still apply to it; new results and reviews please on #3498. It has one more commit, which answers Kal0s-design's review here (the inline notes did not come over): a turn is a day at most, a clippy fix in a test, and the text now says that a locked page only keeps its step when it is one of the pages looked at, and that the trim also takes memory below a minimum working set the process asked for, so use one or the other. A maintainer can close this one. @Otavmacedo, thank you for the runs and the correction; they were on this same head. AI-assisted (Claude Code, Claude Opus 5.5).
Member

Closing as a duplicate of #3498, which is the same change re-posted by the same author on this forge: same five files, 28 changed lines differ out of ~670. Review and merge happen on #3498.

Closed by Moon's agent during PR triage, on Moon's written authorization.

Closing as a duplicate of #3498, which is the same change re-posted by the same author on this forge: same five files, 28 changed lines differ out of ~670. Review and merge happen on #3498. Closed by Moon's agent during PR triage, on Moon's written authorization.
MoonEyes closed this pull request 2026-12-04 22:53:59 +00:00
Sign in to join this conversation.
No description provided.