[pr-fix][memory] RAM trim (soft): a list that gave nothing is not made again at once (the walk of the address space ran back to back, 20 s in 43 s of play) #225
Loading…
Reference in a new issue
No description provided.
Delete branch "blazecoding2009/Darner:pr/ramtrim-list-walk"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Contributor role (optional)
What it changes
The problem on main: the log line below, from v2026.12.03.01 (
ramtrim.rsis the same file onmainf3840d7). WithDARNER_RAM_TRIM=softthe trimmer's thread spent 20.6 s of 600 frames (about 43 s of play) and took nothing out:RAM trim (DARNER_RAM_TRIM=soft), frame 9001: working set 17215 -> 17415 MB over 600 frames, 1426 MB free; taken out MB: driver-cache 0, mapped-file 0, own 0, title 0, whole-process 0 (0 hand-backs); came back 0 MB; 20589 ms spent; held for pipelines 152 timessoft::slicemade its list of ranges again as soon as the last one was gone through. A list with nothing to take (no range, or only ranges whose class is shut or left alone) is gone through in the frame after it was made, so the walk that makes a list ran back to back. That walk asksVirtualQueryabout every region of the process (240,000 in play here, about half a second a walk), each question under the address space's lock.A list is now made again when it is a minute old, as before, and sooner (five seconds after it was made) only when it is gone through and gave something. The rule is a function of its own,
list_due, with a unit test. Nothing else changes: the classes, the gates and what is taken are as they were.How it was tested
Tested revision:
aefb42b(this one commit onmainf3840d7, which is v2026.12.03.02). The "before" lines are from v2026.12.03.01 (bd0de0c), built the same way.Commands and results:
cargo build --locked --profile diag -p darner --features diagnostics: built.cargo test --locked -p darner-gpu --lib ramtrim: 10 passed, the newa_list_gone_through_is_not_made_again_at_onceamong them.Changes a default: no.
DARNER_RAM_TRIMis off by default and only itssoftmode is touched.A/B result: the trimmer's own line, every 600 frames, from the first period in which it did anything (the world loaded, free memory under its line). One run each,
scripts\bench.ps1, the same save, 240 s measured.bd0de0c)aefb42b)The two runs are not the same switch set, and I make no fps claim: A also had #59's four switches and
DARNER_PARK_COMPACT_WASTE=1, B hadDARNER_RAM_TRIM=softalone. A first version of this change (a walk every 5 s whatever the list gave), onbd0de0cwith A's switches, spent 801 to 4791 ms per 600 frames; the commit keeps that figure in the doc comment.Gates run on that revision (the three in AGENTS.md; there is no CI):
cargo clippy --workspace --all-targets --locked -- -D warnings: passed. The same with--all-features: passed.cargo xtask policy: 555 files ok.cargo test --workspace --locked --no-fail-fast: every test binary passed but two, and neither failure is in code this touches:darner-shader: 557 passed, 1 failed, 16 ignored. The one isemit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders, the failure #186 and #163 report onmain.darner-gpu: the run stood still, which #224 is about. A run of the gate before it, with fail-fast, ended there with 1773 passed and 1 failed (host::refresh_tests::refresh_front_zero_arc_matches_and_runs_due, which then passed 3 of 3 times by itself). I ran this revision'sdarner-gputest binary six more times: once all 1774 passed, five times one to three tests failed, ofwatch::tests,watch::watch_pipe_epoch_tests,gpu_owned::testsanddescriptor::tests. The tenramtrimtests passed in all six.mainwithout this change does the same: 4 of 6 runs with a failed test and 1 that stood still (the table in #224).Gameplay: RTX 4050 Laptop 6 GB (driver 621.24), Ryzen 7 8845HS, 32 GB, Windows 11 build 26300. Series S profile, DLSS Quality 1080p to 1440p, DLSS frame generation on, ray tracing off.
Shader wave sizes tested, when relevant: not relevant.
Hardware dependence: likely general. The walk's cost follows the number of regions in the process, not the card.
Coverage gaps: the soft trimmer took nothing out in any of my runs (pipelines were still being made for much of each window,
DARNER_PAGE_MAPwas off and no mirror was idle), so the path where a list gives something and is made again after five seconds ran only in the unit test. One PC.Checklist
main.docs/asset-policy.md.Checked for overlap
ramtrim.rs. Searches of open and closed issues and pull requests forRAM_TRIM,ramtrimandtrimfound nothing on this. #224 is the test standstill named above, not this change.This change was made with AI assistance (Claude Code).
🤖 Generated with Claude Code
I exercised the productive-list branch in a real gameplay process on
aefb42bf. The local build added one trace immediately before the existing list refresh to record list age, bytes taken, scan position and range count. The trim decisions were unchanged.After the first world frame there were 24 refreshes before 60 seconds. Each had exhausted its list, had returned bytes, and waited at least 5 seconds. Ages ranged from 5,000 to 18,484 ms. For example, a list that returned 27,975,680 bytes refreshed at 5,016 ms after scanning 2,292/2,292 ranges. Another returned 87,990,272 bytes and refreshed at 7,828 ms after 633/633. The first empty list had 0/0 ranges and refreshed at 71,081 ms.
The candidate logged 53 complete 600-frame reports. Seven reported title pages returned, 407 MB total as reported. Driver-cache, mapped-file, own, whole-process and came-back counters summed to zero. The game reached the world and exited normally after the requested 180 seconds in-world. For context the stock release pilot also returned title pages (418 MB).
Windows 11, i5-13600KF, 32 GB RAM, RTX 4070 Ti SUPER, 1440p, FG/RT off. I explicitly set
DARNER_RAM_TRIM=soft,DARNER_RAM_TRIM_FREE_MB=16384,DARNER_RAM_TRIM_SET_MB=8192andDARNER_PAGE_MAP=1for the process. This tests refresh behavior under those thresholds. It does not measure default memory pressure or FPS. Tested with Codex assistance.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.