Repository navigation
Render-target reserve expires once the targets settle (LEONIDA_CARD_ROOM_FOR_TARGETS_SETTLE_MS, off by default) - #2589
Conversation
…OOM_FOR_TARGETS_SETTLE_MS, 0 = off by default) PORT-NV-VRAM-TARGET-RESERVE-SETTLE. The texture queue makes no new host copies while in use + kept for buffer copies + kept for render targets reaches 90 % of the card's budget. The target reserve (LEONIDA_CARD_ROOM_FOR_TARGETS_MB, 3,072 MB less the targets made) never expired: at 1440p targets level off at 2.1-2.9 GB, so 160-990 MB stayed kept for targets that never came while thousands of textures waited. With LEONIDA_CARD_ROOM_FOR_TARGETS_SETTLE_MS set, once targets hold half the reserve or more and have not grown by 64 MiB for that many ms, nothing is kept; growth of 64 MiB brings the reserve back. Upstream defaults to 20,000 ms; here it is 0 (kept for the run, as before) because the behaviour would change for everyone. Ported from trustno1-coder/VIctory-NVIDIA 21b040da (readmet3xt-lab), GPL-3.0. Only the reserve change is taken; the same commit's room-test log line and pass timing counters (draw.rs, host.rs) are a separate subject and are left. Co-authored-by: readmet3xt-lab <238408149+readmet3xt-lab@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@DadaCap could you review this one when you have a moment? It merges cleanly with AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes. |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed 0c5dbc424 (d3d12/crates/leonida-gpu/src/resource.rs).
The new opt-in LEONIDA_CARD_ROOM_FOR_TARGETS_SETTLE_MS knob defaults to 0 (off, preserving existing behavior), and the pure targets_seen / targets_kept helpers use saturating arithmetic with clean boundary handling around the settle window.
Local verification:
cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib room_for_targets: 1/1 passed (resource::tests::room_for_targets_is_given_up_once_they_settle).python -I scripts/check_no_game_data.py: passed.
AI-assisted (Antigravity, Gemini).
Only with LEONIDA_CARD_ROOM_FOR_TARGETS_SETTLE_MS set; the default path returns before it. Lets a run show when the reserve expires and how many MB go to textures, for the A/B test of this setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Answer with |
Physical Hardware Verification — Windows 11 + NVIDIA GeForce RTX 3090 (
|
lixonik
left a comment
There was a problem hiding this comment.
Reviewed the logging follow-up at 2058ecb5b. Reproduced one non-blocking accounting-log corner with a synthetic fixture built from the current Rust helpers and transition predicate.
AI-assisted.
| // One line each time the reserve is given up or taken back, for a run to | ||
| // show when and how much (none with the setting at 0). | ||
| static GIVEN_UP: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); | ||
| let given_up = kept == 0 && targets < most; |
There was a problem hiding this comment.
When settled targets grow straight to the cap, this flag flips even though the reserve stays at zero. With a 3072 MiB cap, my fixture held 2432 MiB through the 20 s settle threshold, then grew to 3072 MiB. The emitted lines say "640 MB freed for textures", then "taken back ... 0 MB kept". Could the take-back message require kept > 0, so a reader can use it as evidence that textures lost budget again? The reserve calculation itself gives the expected zero.
There was a problem hiding this comment.
Verified the fix on ee27e8719 on native Windows 10 22H2 (MSVC, Rust diag). resource::tests::room_for_targets_is_given_up_once_they_settle passed. It covers the 2432 to 3072 MiB jump with zero reserve and no take-back, and a separate growth event that restores a positive reserve. This addresses my logging comment.
AI-assisted.
|
TAKEN | OreoFR (oreofr-agent, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) | ETA 22:47 UTC |
|
Tested
No blocker from my side. AI-assisted (Claude Code). |
|
TAKEN | enlight3d | ETA 03:45 UTC. Note: RTX 3090 24 GB (outside the 8-12 GB in NEEDS); a 24 GB replica, as MoonEyes asked. |
#2589 TEST-WANTED: LEONIDA_CARD_ROOM_FOR_TARGETS_SETTLE_MS, A = 0 / B = 20000Local test, AI-assisted (Claude Code, Claude Opus 5.5). Values only: no captures, logs or game paths leave this machine.
RUN p2589-A3RUN p2589-B3RUN p2589-B4RUN p2589-A4VerdictPrediction refuted on this profile (Series S + DLSS, 8 GB), n=2 per arm: B never wrote a "given up" line (0 in Why, READ IN CODE ( B3's crash (718 s, title crash handler) did not come back in B4 (900 s, no crash). In B3, Windows held the game's
|
|
RUN A | 2026-11-29 02:51-03:06 UTC | enlight3d | AI-assisted: Claude Code (Claude Opus 5.5) RUN B | 2026-11-29 03:07-03:22 UTC | enlight3d | AI-assisted: Claude Code (Claude Opus 5.5) B - A (n=1 each, PROVISIONAL): 300 s: card-wide +811 MiB, process's own +1,037 MiB (runtime's "textures picked by index, uploaded so far" counter +3,883 MB: 12,423 vs 8,540 MB); 900 s*: +381 / +389 MiB. World 71 vs 74 s; frame rate 18.5 vs 18.3; both ended at the limit. Not as asked / confounders: 24 GB card; order A then B, not alternated, and B started with a slightly warmer pipeline cache (its precompile made 234 more pipelines in 24 s; A's made 2,003 in 326 s); desktop video memory differed by 105 MiB before the runs (the process's own numbers don't include it); built for the MSVC target named explicitly (this machine's Rust default is GNU) and without DLSS (the default 1440 path doesn't use it). *The "900 s" values are the samples at 897 s of the game process, stopped at 900 s. What would disprove the result: B using no more memory than A in repeats with the order alternated. |
|
DONE | #2589 (comment) |
# Conflicts: # d3d12/README.md
lixonik (review, resource.rs:1903): targets that settle under the cap and then grow straight to it flip the flag and write "taken back ... 0 MB kept", which a reader takes for textures losing room. The turn is now a pure function, targets_turn: given up when nothing is kept below the cap, taken back only with kept > 0, no line otherwise. The reserve itself is unchanged. Tested: the new asserts in room_for_targets_is_given_up_once_they_settle (lixonik's fixture: 2432 MiB settled, then 3072 MiB) compiled and run on their own with rustc; the crate's lib tests build on Windows only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDMsHtPdJ5kt8t7A5i2fzu
|
Reserve growth timestamp can move backward on I reproduced the ordering with synchronized threads and the unmodified Could the opt-in branch read the observation and update its watermark and transition under one lock, while keeping the early return for |
|
12 GiB Linux 1440p follow-up. I observed the reserve being released and taken back with
With |
# Conflicts: # d3d12/README.md
… only) merzleckeier (ProjectLeonida#2589, 11:55): targets_room_kept read the growth record (GREW) and the given-up flag, computed, then stored them back as separate atomics. A caller delayed between its read and its store put back an older record: with synchronized threads the reserve kept 0 MiB where 709 were due. Not seen in game. The record, the flag, and the targets' bytes and the time they are compared with are now read, computed and stored under one Mutex, so no store can go back in time. The default (setting 0) returns before the lock and stays lock-free. Tested: cargo check -p leonida-gpu --target x86_64-pc-windows-gnu (MinGW) passes with the same 19 warnings as before; the function is Windows-only and was not run. Not done: a threaded test of the race. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDMsHtPdJ5kt8t7A5i2fzu
|
Retested the stale-write case on
This verifies the reported ordering with synthetic inputs. AI-assisted with OpenAI Codex. |
|
Thanks, fixed in ee27e87: the growth record, the given-up flag, the targets' bytes and the time are now read, computed and stored under one Mutex. Only the opt-in branch (SETTLE_MS > 0) takes the lock. Checked with cargo check for Windows; no threaded test of the race yet. |
|
Threaded test of the stale-store fix on native Windows. AI-assisted (Claude Code, Claude Opus 5.5).
Limits: like merzleckeier's test, this is a forced interleaving with synthetic inputs. No in-game occurrence was looked for. The |
|
Mechanical note, no review: this branch conflicts with
That file is a hot spot in this checkout - several open pull requests edit it ( So a rebase is all it needs - the change itself may well be fine, I have not looked at its content, only at whether git can apply it. Written with an AI assistant. |
# Conflicts: # d3d12/README.md
# Conflicts: # d3d12/README.md
# Conflicts: # d3d12/README.md
# Conflicts: # d3d12/README.md
|
RUN (independent run, #2589 head 71cccc0 on main e1fe82f; merged locally with Commands, in
Perf: only with the setting on. Showing that textures get room sooner needs an in-game A/B with No runtime/ C++ or Python in this PR, so no link or import check applies. |
…eserve-settle Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
IN-GAME RUN (gate, independent): #2589 head 47cbe15 (main d367675 already merged into it), RTX 3090 24 GB, NVIDIA 621.40, Windows 11. Setup: Gate: no device loss on this PR's build in 4 of 4 runs (warm-up, throwaway, two measured 600 s runs). World reached at 70 and 76 s.
The setting never acted here, so this does not measure the PR's effect. No "given up" / "taken back" line in either B run. The reserve is 3,072 MB and is given up only once the world's render targets hold half of it (1,536 MB). In Series S they peak at about 1,260 MB on this card. So A and B behave the same in this profile, and the fps gap follows a late slowdown seen in some runs on every build (B-2 here). That slowdown is being tracked separately: on this card, list scratch kept in card memory and the release thread's queue keep growing in some runs. Measuring the PR's effect needs Series X (render targets 2-2.9 GB here); I can run that once the late slowdown is understood, since it would confound the comparison now. The A-2 crash is on main's build, not this PR's. Not checked: Series X, walking, picture. |
|
Independent check on Windows (not the author), at
The reserve-expiry/frame-time behaviour needs a game run, which I did not do; this confirms the crate and existing tests stay green with the change. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned. AI-assisted: yes (opencode). |
|
RUN (independent re-run on Windows, #2589 head 47cbe15, tested as it is: it already has main d367675 merged in. This replaces my earlier RUN on 71cccc0. The PR's own changes, Commands, in
No runtime/ C++ or Python in this PR, so no link or import check applies. |
Item: PORT-NV-VRAM-TARGET-RESERVE-SETTLE
Claim: #2570 (comment)
Source: trustno1-coder/VIctory-NVIDIA 21b040da (GPL-3.0), author readmet3xt-lab (credited in the commit with Co-authored-by and in the
d3d12/README.mdtable).The texture queue makes no new host copies while in use + kept for buffer copies + kept for render targets reaches 90 % of the card's budget. The target reserve (
LEONIDA_CARD_ROOM_FOR_TARGETS_MB, 3,072 MB less the targets made) never expires: at 1440p the targets level off at 2.1-2.9 GB, so 160-990 MB stay kept for targets that never come while thousands of textures wait.With
LEONIDA_CARD_ROOM_FOR_TARGETS_SETTLE_MSset, once the targets hold half the reserve or more and have not grown by 64 MiB for that many ms, nothing is kept; a growth of 64 MiB brings the reserve back. Upstream defaults to 20,000 ms. Here the default is 0 (reserve kept for the run, as before), because the behaviour would change for everyone. With the default, the code path is the one onmain.Only the reserve change is taken. The same upstream commit's room-test log line and pass timing counters (
draw.rs,host.rs) are a separate subject and are left out.Test:
room_for_targets_is_given_up_once_they_settle(cargo test -p leonida-gpu --lib room_for_targets), no game files. It does not compile onmain(the functions do not exist), and fails when the settle branch is cut. Passes on this branch merged withmain5cb4592. Crate-wide, the same 4 tests fail with and without the change (descriptor::hostviews_off_their_elements_get_a_copy_of_their_bytes,indirectbatch_tables,host_list_budget_starts_empty_at_each_submission,warp_batch_charges_every_execution). Not run in the title or on a GPU: the 20,000 ms value is upstream's measurement, not ours. May touch the same lines of text as #2569 (resource.rs) and #2557 (README table).AI-assisted (Claude Code, Claude Opus 5.5 and Sonnet 5.5); reviewed by a separate agent before opening.
🤖 Generated with Claude Code