[pr-fix][pr-performance][vram] Settle speculative +50% render-target peak reserve once targets stabilize #564
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!564
Loading…
Reference in a new issue
No description provided.
Delete branch "(deleted):pr/targets-room-peak-settle"
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:
In
crates/darner-gpu/src/resource.rs(targets_room_kept),DARNER_CARD_ROOM_FOR_TARGETS_SETTLE_MS(default20,000 ms) andtargets_seengrowth tracking are computed unconditionally, butsettleis only passed totargets_keptwhenDARNER_CARD_ROOM_FOR_TARGETS_MBis explicitly set (FLATpath). On the defaulttargets_kept_from_peakpath (targets_kept_from_peak(most, targets, peak)),settleis never consulted. As a result, once world render targets stabilize belowmost(e.g.~1.8 GBat1080to1440DLSS Quality or390 MBon Series S), the speculative+50%growth margin (peak + peak/2 - targets) stays permanently reserved (966–971 MBon RTX 5070 Ti) even minutes later, prematurely trippingthe texture queue's room(no room, new textures wait).What this does:
Adds
targets_kept_from_peak_settled(most, targets, peak, still_ms, settle)and wires it intotargets_room_kept: once a real set of render targets (>= 256 MiB) has not grown by64 MiBforsettlems, drop the speculative+50%growth margin and keeppeak.min(most).saturating_sub(targets)(0at steady state, while still preservingpeakprotection if targets transiently drop in a menu or cutscene). Whenevertargets_seenobserves>= 64 MiBgrowth again, the full+50%growth margin returns immediately;DARNER_CARD_ROOM_FOR_TARGETS_SETTLE_MS=0preserves legacy behavior.How it was tested
Tested revision:
c8258f9+f43bed1(pr/targets-room-peak-settle)Commands and results:
scripts/bench.ps1(cargo build --profile diag --locked -p darner --features diagnostics), comparingDARNER_CARD_ROOM_FOR_TARGETS_SETTLE_MS=0(A, legacymain) vs default20,000 ms(B, this PR) from the same binary, save seed, and input route (30 s warmup + 90 s window, 1 run each):Changes a default: yes — default
DARNER_CARD_ROOM_FOR_TARGETS_SETTLE_MS=20000now applies to the default peak-based render-target reserve path on all setups (=0disables it).A/B result:
1080to1440, DLSS Quality, FG 3, High textures,DARNER_SAMPLED_MARKS=0,DARNER_RDNA_FLOAT=2)off,settle=0)on, default20s)kept for render targets966–971 MB0 MBno_room/room)23 / 1011 / 22texture copieson card1,855 MB(1,667–1,922 MB)2,512 MB(2,470–2,652 MB)neutral shown / written127,589 / 2,611,264(4.89%)119,762 / 3,161,036(3.79%)4500–7000 drawsband FPS (matched scenes)25.1 fps(39.8 ms, IQR35.3–41.7 ms; 7 lines)29.7 fps(33.7 ms, IQR33.3–35.3 ms; 17 lines)30.3 GB29.9 GB0 / 00 / 0(Transparency note: overall window median was
32.0fps in A vs29.5fps in B only because Run A happened to spend 8 frame lines in a500–2000 drawsview whereas Run B spent 17 frame lines in4500–7000 draws; the matched4500–7000 drawsband gives the apples-to-apples performance comparison.)Gates run on that revision:
cargo xtask policy:576 files okcargo clippy --locked -p darner-gpu --all-targets -- -D warnings: 0 warnings (default &--all-features)cargo test --locked -p darner-gpu -- --skip oracle64:1,806 passed, 0 failed(81 ignored), including new unit testresource::tests::room_for_targets_from_peak_settles_speculative_margin.Gameplay: NVIDIA GeForce RTX 5070 Ti 16 GB, Intel Core Ultra 7 265KF, 64 GB DDR5-6400, Series X profile,
1080to1440, DLSS Quality, MFG 3, RT default (off).Shader wave sizes tested: 32 and 64 lanes (
DARNER_EXACT64=71883e40620a567a+7168dd781ca7efb9,DARNER_SAMPLED_MARKS=0).Hardware dependence: likely general across GPUs/profiles where
targets < DARNER_CARD_ROOM_FOR_TARGETS_MB(unit tests cover 390 MB Series S / 8 GB and 1,800 MB 1440p scales); runtime A/B tested on RTX 5070 Ti 16 GB.Coverage gaps: Runtime A/B measured 1 run each on RTX 5070 Ti (16 GB); 8–12 GB GPUs and AMD cards covered by unit tests only.
Checklist
main.docs/asset-policy.md.Checked for overlap
I checked the post-growth re-arm on
1d27f243. This PR makes the default peak-reserve path use the existingGREWpair. The texture pass anddarner-texture-sweepcan both update it, andtargets_room_keptreads and writes the size and timestamp separately (resource.rs:3742–3754).One possible ordering starts with
(1800 MiB, 1000 ms)after settling. The texture pass samples 1800 MiB and writes back the unchanged size. The sweep observes 1900 MiB at 25000 ms and writes both fields. The texture pass resumes and writes its old timestamp. On the next 1900 MiB sample at 25001 ms, the pair now looks settled and the growth is missed. With a 3072 MiB limit and 20 s settle, my CPU model gives 0 MiB of reserve in that ordering and 950 MiB with a coherent update.I would sample and update the two fields together, for example with a small lock around the atomic counter reads and the state transition. A regression for re-arming after growth would complement the existing reserve-formula test. This is a source review and CPU model. I have not observed the interleaving in a GPU run.
Reviewed with Codex and Claude Code.
Thanks
@tyr0nsur— great catch on the tornGREW/PEAKupdate between the texture pass anddarner-texture-sweep. Implemented and verified locally onpr/targets-room-peak-settle(f55fef5; will push when back at the keyboard for push/upload confirmation):PEAK: AtomicU64+GREW: [AtomicU64; 2]with a singleMutex<(u64, u64, u64)>(STATE) intargets_room_kept(crates/darner-gpu/src/resource.rs) guarding the target byte sample, timestamp read,(peak, last, since)transition (targets_room_step), and reserve calculation together.targets_room_step_rearms_coherently_after_growthcovering the1,800 MiB @ 1,000 ms-> settled0 MiB @ 25,000 ms->1,900 MiB @ 25,000 ms/25,001 mssequence (asserts950 MiBre-arm holds and re-settles cleanly at45,000 ms).Local checks on
f55fef5:cargo xtask policy(576 files ok),clippy --all-targets -- -D warnings(0 warnings),cargo test --locked -p darner-gpu resource::tests -- --skip oracle64(79 passed, 0 failed,1device-specific ignored).1d27f243on an RTX 4070 Ti 12 GB with hardware RT: the reserve is given back and the queue opens as described, but here it comes out about 1 fps slower than plain, not faster.PC and method: RTX 4070 Ti 12 GB, driver 621.24, Ryzen 7 7800X3D, Windows 11. Own release builds: A is plain
9b288a70(v2026.12.04.01), S is the same with this PR's commit on top. 1440p output, DLSS Quality, hardware RT, frame generation off, no cap. One save, standing with scripted camera turns, 10 min a run, counted from 120 s. Order A S S S S A, same shader cache,DARNER_QUEUE_GAPS=1on all six.Two A runs against four S, and the S runs spread over 2.5 fps on heavy seconds, so I'd call it "no gain on this 12 GB card with RT, possibly a 1 ms cost" and not more. Your 5070 Ti numbers were with RT off, frame generation on and 16 GB, so both can be true. If it stays on by default it may be worth a second 12 GB run from someone else.
Tested merged onto
c8258f95(release), head1d27f243. RTX 3090 24 GB, driver 621.24, i5-10600K, 32 GB, Windows 11.One unattended run, 60 s in the world, frame generation off. The texture queue line in the log, at the end of the run:
main:535 MB kept for render targets8 MB kept for render targetsExit code 0, no new kind of WARN or ERROR line. This was not an fps A/B (one run each, and this CPU is the limit here), so it says nothing about speed.
AI-assisted testing (Claude Code, Claude Opus 5.5); results and text reviewed by me.
Closing as obsolete: this PR targeted the old pre-merge renderer and is no longer needed on post-merge.
Pull request closed