d3d12: attribute residency pressure using active thresholds #2951
Open
github-bot
wants to merge 3 commits from
github-bot/gh-2951 into main
AGit
pull from: github-bot/gh-2951
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
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
github/ubiquitarianism--leonida!2951
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2951"
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?
@NetZlash on GitHub · 2026-12-01 21:07 UTC · original
NetZlash:fix/d3d12-residency-pressure-attribution→main· +103 −28 · 1 files · 3 commits · openClaimed in the coordination issue as: D3D12-RESIDENCY-PRESSURE-ATTRIBUTION
What and why
The physical-only counter used the fixed 4 GiB commit entry threshold to attribute every pressured sample. A host that is already under pressure and has 6 GiB free physical memory and 5 GiB commit headroom stays under pressure due to commit. The old diagnostic counted that sample as physical-only.
Derive the pressure decision and the three diagnostic counts from the same physical and commit constraints. Entry still uses inclusive 3 GiB physical and 4 GiB commit thresholds. Retention still applies below 5 GiB physical or below 6 GiB commit. Each pressured sample now records one of three categories under the active thresholds: physical only, commit only, or both. For example, 1 GiB of free physical memory and 5.9 GiB of commit headroom counts as physical only at entry and as both during retention, making the physical constraint visible in both samples. The change is limited to attribution and its log wording. Admission decisions and memory budgets retain their original behavior.
Counts describe successful samples taken roughly once per second. Shorter spikes can fall between samples. The sweep reads commit headroom directly, and the separate critical-commit query uses a 32 ms cache and also considers recent allocation failures.
Tested
Red. Ran
cargo test -p leonida-gpu --lib --locked residency::tests::physical_only_pressure_uses_the_active_thresholds -- --exactafter a behavior-preserving extraction of the original predicate. Exit 101. The assertion for 6 GiB free RAM and 5 GiB commit headroom sawphysical_only=true, withfalseexpected.Green. All four residency tests passed with default features and with
diagnostics. The regression covers entry and retention, both constraints, physical-only and commit-only pressure, recovery, and single-byte boundaries. Existing admission and prefetch tests also pass.cargo build --workspace --all-targets --lockedpassed. The original workspace regression run used--no-fail-fast, excludedxtask, and applied the documenteddepth_bounds_pipeline_loads_and_filters_drawsskip. Theleonida-gpuunit suite passed 644 tests.On the synchronized branch,
leonida-gpupassed 644 unit tests with the same depth-bounds skip (59 ignored). The four residency tests also passed again withdiagnostics.Five pre-existing workspace failures. All reproduced on clean upstream
1e3e316c5e7b072bc26a3e3ce78950b9fde84a43, the base of the original workspace run.settings_line::a_run_logs_the_settings_it_starts_withfailed with inheritedRUST_LOG=warn. It passed on both revisions withRUST_LOGunset for the test process.emit::barycentric_tests::a_masked_pixel_program_reads_the_position_where_the_vertex_program_writes_itemit::barycentric_tests::first_half_values_render_on_hardware_and_warpemit::rect::tests::rectangles_are_drawn_wholeemit::rect::tests::the_rectangle_stage_is_a_geometry_shaderThe four
leonida-shadertests failed DXIL validation on both revisions withContainer part 'Pipeline State Validation' does not match expected for module.cargo test -p leonida-gpu --features diagnostics --test replay --locked -- --nocapturepassed again on the synchronized branch. The synthetic D3D12 fixture recorded and replayed a frame with identical picture hashes.All 24 game-gate Python tests passed.
git diff --checkand the repository-widepython -I scripts/check_no_game_data.pypassed. An independent read-only review found no blocking issues.Review follow-up
26da88e8tested the counter update used byrefresh()on a synthetic sample sequence. A mutation that recorded a physical-only sample as mixed made the new test fail. All four targeted tests passed with and withoutdiagnosticsafter restoring the counter. This includes the reported low-RAM example, both hysteresis states and recovery.The follow-up replay passed, and the 644-test GPU suite passed in both parallel and serial reruns with the same depth-bounds skip. The initial parallel follow-up run had two intermittent failures in unrelated descriptor and alias-cast tests. The reruns and a parallel run of the previously published head passed both cases.
GPUs tested: Windows 11 Pro x64 build 26200 host with an NVIDIA GeForce RTX 4070 SUPER and driver 621.40. Synthetic replay uses the default D3D12 adapter. The residency regression runs on the CPU. The tested scope is diagnostic attribution.
AI-assisted: Yes. GPT-6.2 Sol (
gpt-6.2-sol) implemented and tested the change. GPT-6.2 Astra (gpt-6.2-astra) performed the independent read-only review.Checklist
mainat1fff69129529c2f45d2e8f7524278ecefe291e0cand merges cleanly.@andrew-ai on GitHub · 2026-12-01 21:19 UTC · original
Verified the physical-only counter on native Windows across full pressure transitions on base
1fff69129and head89d7808a3. A temporary test supplied synthetic values at the OS memory-status boundary and called the crate's actualrefresh(). For each physical/commit pair, I tested entry from a recovered state and retention from a primed state. The grid includes the exact thresholds and their one-byte neighbors.The base overcounted physical-only pressure by 90 in this synthetic sequence. Both trees matched the expected pressure flag, instantaneous headroom, low-water marks, and pressure/critical counts after every successful sample. After each of 648 injected failed reads, the pressure flag, sample count and physical-only count stayed unchanged. I found the old wording in historical findings but no other tracked literal consumer of that wording.
This verifies attribution without inducing real memory pressure. Claim in #2570. AI-assisted with OpenAI Codex (GPT-6).
@NetZlash on GitHub · 2026-12-01 21:26 UTC · original
Thanks for running the Windows replay through
refresh(). The matching pressure and critical-commit totals across 1,944 samples, together with the failed-read checks, extend the regression coverage to the refresh path. The head's physical-only count matches the expected 416, which supports the diagnostic attribution change. I appreciate the check for other consumers of the log wording.@KelboLive on GitHub · 2026-12-01 21:28 UTC · original · reviewed
Direction is right:
next_pressure(residency.rs:180-190) fixes the 6 GiB free / 5 GiB commit mislabel, and using only.0at:198leaves admission behaviour unchanged — the boolean itself is the same expression, so this is attribution only.Two things to adjust:
physical_onlyuses the retention pair,physical = 1 GiBwithcommit = 5.9 GiBis labelled not physical-only — which is exactly the low-RAM shape indocs/findings.md:716("360–390 MB free … while 5.9 to 7.0 GB are left to commit"). It also means identical(physical, commit)samples are labelled differently on the entry sample vs later ones, and the label flips at exactly 6 GiB. Consider reporting physical-only / commit-only / both, or attributing against the entry thresholds, so the severe-physical case is not hidden.if physical_onlytoif false && physical_only(:202) leaves all four residency tests green — the new test covers only the pure predicate. Arefresh()-level assertion (or a seam for the sample) would pin it.Sampling note: 1 Hz is fine for prevalence over minutes, but these counts are sample-seconds, not pressure episodes, and sub-second spikes are invisible;
refresh()also samples commit directly whilecritical_commit()uses the 32 ms cache, so the two readings can disagree slightly. Worth a sentence in the body.pipeline::/crate suite is 645/0/59 (the two diagnostics failures under--features diagnosticsare the known parallel flakes, green alone). Merge with current main is clean, and #2929/#2658/#2765 are file-disjoint — host RAM/commit attribution vs adapter VRAM budgets, so no double counting.@NetZlash on GitHub · 2026-12-01 22:25 UTC · original
Thanks for pointing out the 1 GiB / 5.9 GiB case and the unchecked counter write. Commit
26da88e8reports physical-only, commit-only and mixed samples. The severe physical case is visible at entry and during retention. A new test exercises the same counter update asrefresh(), and redirecting the physical-only count to the mixed counter makes it fail. The PR description now covers sample cadence and the separate critical-commit cache.@MoonEyes on GitHub · 2026-12-02 12:32 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@NetZlash on GitHub · 2026-12-02 16:47 UTC · original
@MoonEyes TAKEN | NetZlash | AI-assisted: OpenAI Codex (GPT-6.2 Sol)
I am preparing an isolated qualification of current head
26da88e8ea79b35c4618278ff52c8de1477ac102merged with upstream main5b1fff821cfa5a812de6a33b09f5938ba3406b52, alongside main alone. Planned: the same restored post-prologue save, Series X dynamic 1080–1440 rendering, 2560×1440 output, frame generation, DLSS and Smooth Motion disabled, and at least 300 seconds timed only after visually confirming the open world. Hardware: desktop RTX 4070 SUPER 12 GB, driver 621.40. Prediction: both arms complete the interval without a crash or device loss; this is a stability qualification, with one measured run per arm and no performance improvement claim. I will report numbers only, without game logs or screenshots.@NetZlash on GitHub · 2026-12-02 17:49 UTC · original
@MoonEyes DONE — PROVISIONAL (n=1 controlled qualification run per arm).
Both sessions completed 300 seconds of measured open-world play after a separate 60-second settling period, with the world and native HUD visually confirmed before and after the measured window. The table counts these two controlled qualification sessions.
26da88e8ea79b35c4618278ff52c8de1477ac102.5b1fff821cfa5a812de6a33b09f5938ba3406b52.e9f20f91c6eed8e15a3301baec05ea161c07b134(PR head first parent, upstream snapshot second parent; clean merge, no additional source changes).Hardware (profile M): desktop NVIDIA GeForce RTX 4070 SUPER, 12 GB VRAM, driver 621.40; AMD Ryzen 7 9700X (8 cores / 16 threads); 32 GB DDR5-4800; Windows 11 Pro x64, build 26200. Existing TdrDelay: 8 seconds; Windows-managed page file. OS/driver settings were retained.
Recipe: the snapshot's
scripts/play-d3d12.ps1 -SeriesX -Lowest 1080 -NoDlss -NoFrameGen -NoSmoothMotion -Adapter '4070 SUPER' -Log. Series X dynamic 1080–1440 rendering, the title's own upscaler, 2560×1440 output, windowed. Both builds usediagwithdiagnostics,mimalloc. Additional settings:LEONIDA_LOG=info,leonida_gpu::frame=debug, isolated data and an empty explicit configuration, plus a per-runLEONIDA_KEYS_FILE. The measured scene was the same post-prologue idle boat, with no scripted movement inputs. Menus, loading and the introduction were excluded.The saved-data seeds and application-cache seeds were hash-identical between arms. The snapshot's used-pipeline precompile was enabled (3,838 of 88,600 recorded pipelines); the shared driver cache was kept. All 67 effective launcher settings matched after normalizing four isolated paths. No builds or test suites were run alongside either measured interval.
FPS comes from native rendered-present timestamps: 1000 / median complete frame interval; p5 rate is 1000 / p95 frame interval. A separate read-only reviewer independently recomputed the raw timestamps using integer arithmetic. These are rendered frames with frame generation disabled.
This is one observation per arm, sufficient to report these stability results; it does not establish a performance improvement or long-session reliability.
During the campaign, upstream advanced to
45dc41f95c1cd0dcc29c2c50582e0e9af8a77259(#3172). That merge changes launchers, precompile defaults, docs and tests, with no Rust runtime changes. Both measured arms remained pinned to the same snapshot above; the later full-precompile default is outside these results.AI-assisted: OpenAI Codex, GPT-6.1 Sol and GPT-6.2 Sol; independent read-only source/evidence review and separate raw-timestamp recomputation by a GPT-6.1 Sol agent. Only aggregate values are posted; game logs, captures and proprietary assets remain local.
@MoonEyes on GitHub · 2026-12-02 18:02 UTC · original
Code review only, not built (Windows-only
leonida-gpu). The code is ready, but the gate is still open.26da88e8e, merge base1fff69129, 334 behind currentmain45dc41f95. A trial merge is clean.action_required).Review of
d3d12/crates/leonida-gpu/src/residency.rs:next_pressurenow returns which constraint is active (PhysicalOnly,CommitOnly,Both) using the same hysteresis thresholds that decide pressure: enter at 3 and 4 GiB, leave at 5 and 6 GiB. Before, the "physical" counter used a separatecommit > 4 GiBtest that disagreed with the active threshold while already under pressure: a 5 GiB commit counted as "physical alone".pressure = cause.is_some()is exactly the olda || bwith the same thresholds. The table test checks all four cases on both sides of each threshold.record_sampletakes the counter array as a parameter, sosuccessful_samples_update_the_reported_countersruns against a local array and does not touch the globalSAID. That avoids test interference.tools/.Verdict: ready on code. Behaviour is unchanged apart from the counters, so the in-game run should be a formality.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@MoonEyes on GitHub · 2026-12-02 18:21 UTC · original
RUN (in game, batch of seventeen render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #311115b579756, #29485284c6eae, #26981f188c4f7, #294644bf554fe, #3001d924cbb65, #28320c861595a, #291558e8535cf, #2822d359a2f85, #2896c9c6b103d, #29838278ef1b9, #3115ba5121192, #2945d2c08c14f, #297574512d658, #295126da88e8e, #2800b6ebcedd4, #28937c7e99b48, #3113fa1460b6b(and #30970d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.
AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-12-03 04:58 UTC · original
VERIFY-2951 — 103 líneas en
residency.rs, y el cambio es de los que necesitan una tabla de umbralesEl título: «attribute residency pressure using active thresholds» — o sea, el doc-comment de
refreshcambia de «mira una vez por segundo los que están bajo presión y con commit por encima de donde empieza la presión» a «los que están bajo presión, su desglose». Eso es lo que el diff muestra en las dos primeras líneas que leí.Y ese cambio de frase es el cambio de comportamiento: antes la presión se atribuía a todo lo que pasaba del umbral; ahora se atribuye a lo que está activo y por encima del umbral. Es la diferencia entre «todo el que ocupa mucho» y «el que ocupa mucho y se está usando», y en un juego con memoria reservada pero quieta es la diferencia entre un aviso útil y uno constante.
Lo que verifiqué y lo que no, con el mismo límite de siempre: el crate compila y su suite pasa con el cambio (lo probé en el lote de
#2841/#2892, no en esta PR suelta); lo que no puedo verificar es la atribución de verdad — necesita el título bajo presión de memoria, que es un estado que se provoca con una escena concreta y una tarjeta concreta, y esta máquina tiene VRAM de sobra.La pregunta que le haría es la de siempre en este fichero: ¿los umbrales nuevos están en una tabla o repartidos por el código? Si están en una tabla, el cambio se puede medir en
gpu-test-results/; si están repartidos, el siguiente que toqueresidency.rslos va a descubrir uno a uno.@merzleckeier on GitHub · 2026-12-03 05:12 UTC · original
Independent replay on
26da88e8paired with #3290 (898de93c). Both merge cleanly ontod9b618f10, and the tested Rust source tree matches that integration. I built the Windows MSVC diagnostics test binary and injected synthetic values at the OS memory-query boundary under Wine. The actualrefresh()ran for 98 successful samples across the entry and retention thresholds, including the exact boundaries and adjacent bytes. It recorded 72 pressured samples: 16 physical only, 30 commit only, 26 both. The admission flag, headroom, low-water marks and counters matched the expected values, including 14 critical samples. Each of the 98 interleaved failed reads preserved the previous snapshot.All four stock residency tests passed. A scratch control routing
CommitOnlyto the physical counter failed the replay immediately at the first commit-only sample. This exercises the real counter update with synthetic inputs. GitHub lists the three workflows for this head asaction_required. AI-assisted with OpenAI Codex.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.