d3d12: the card's spare scratch that nobody asks for is let go where the card is short #3497

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "d3d12-scratch-spare-idle:Krashgamer-d3d12-scratch-spare-idle"
git switch "Krashgamer-d3d12-scratch-spare-idle"
Open
leonida/mandy
Krashgamer wants to merge 7 commits from Krashgamer/mandy:d3d12-scratch-spare-idle into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'd3d12-scratch-spare-idle:Krashgamer-d3d12-scratch-spare-idle'
git switch 'Krashgamer-d3d12-scratch-spare-idle'
First-time contributor

Replaces #3321, which came over from GitHub under the name Ghost, so I can no longer push to it. Same code as #3321 (head 0bf2c1732, the commit the test reports there name). The discussion and test results so far are on #3321.

Claimed in the coordination issue as: D3D12-SCRATCH-CARD-SMALL-CARDS (https://git.leonida.now/leonida/mandy/issues/2570)

What and why

The lists' spare scratch in the card's memory grew to its limit (a sixteenth of the card's budget) and stayed there: five minutes in the world, 543 of 587 MB were spare on a 10 GB card that was full. The title's textures were let go meanwhile for lack of room.

Now, where the card is past 85 % of its budget, spare chunks in its memory that no list took for ten seconds go: at most 32 of them and 32 MB a second, and 32 MB always stay. Where the card has room, or its use is not known, nothing goes (keep_freed as before). They are freed on the reaper thread by default, not under the submission lock. Exceptions: with LEONIDA_BURY_LAG=0 and no submission running they are dropped at once on the sweeping thread; with LEONIDA_REAPER=0, or the reaper's line full, on the thread that buries. LEONIDA_SPARE_IDLE=0: as before.

Tested

Series X, 2560x1440, game gate 300 s in the world, counted from a minute in; the second half of each run for the memory. With it / with LEONIDA_SPARE_IDLE=0:

ray tracing (-HardwareRT), 2 pairs no ray tracing, 1 pair
Card, MB 8,499, 8,450 / 8,763, 8,745 8,189 / 8,228
Title's textures alive, MB 1,730, 1,691 / 1,514, 1,468 2,970 / 2,728
Frames a second, median 20.95, 21.34 / 21.50, 21.12 23.47 / 23.36
Frames a second, 5th percentile 12.2, 12.2 / 12.0, 12.1 14.0 / 14.3
Stutters of 250 ms, of 1 s and more (all runs) 57, 11 / 57, 11 5, 3 / 6, 1

These are from a local build of main 8877be372 with #3495, #3496 and switches that were off.

This branch's own build on main d9b618f10 alone (without #3495 and #3496), one -HardwareRT pair, with it / with LEONIDA_SPARE_IDLE=0. The card is over its budget of 9.2 GB in both runs:

with it without
Card, MB (second half) 9,528 9,949
Title's textures alive, MB (second half) 1,435 1,465
Frames a second, median (5th percentile) 21.2 (11.2) 19.9 (10.8)
Stutters of 250 ms, of 1 s and more 30, 2 40, 8

The textures gain nothing there; where the room went was not looked at. The first table is from a build with #3495 and #3496, where the card was at 8.2 to 8.8 GB. One pair says little about speed and stutters.

  • The speed of one pair each says little: without it 21.50 and 21.12, with it 20.95 and 21.34. No claim about stutters from driving; nobody drove it yet, the route was the same in every run.
  • Earlier forms freed on the submitting thread; five pairs had 38 stutters of 1 s and more against 27. It is not told apart from chance, but that is why the freeing moved.
  • The churn guard (more than 1,000 chunks made in 10 s) tripped in none of the runs.
  • Unit tests the_spare_pool_lets_the_idle_go and a_large_spare_does_not_keep_the_others: fail with the rule taken out, pass with it. All unit tests of the branch: 799 passed, 0 failed, 59 ignored (leonida-gpu, diagnostics, mimalloc).
  • Two review passes by a separate agent before this; what they found is fixed (chunks in use could go, many releases under the lock, a large chunk in front kept the others, a card whose use is not known).
  • Not tested: other cards. Where the card has room the rule does nothing.

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

Replaces #3321, which came over from GitHub under the name Ghost, so I can no longer push to it. Same code as #3321 (head `0bf2c1732`, the commit the test reports there name). The discussion and test results so far are on #3321. Claimed in the coordination issue as: D3D12-SCRATCH-CARD-SMALL-CARDS (https://git.leonida.now/leonida/mandy/issues/2570) ### What and why The lists' spare scratch in the card's memory grew to its limit (a sixteenth of the card's budget) and stayed there: five minutes in the world, 543 of 587 MB were spare on a 10 GB card that was full. The title's textures were let go meanwhile for lack of room. Now, where the card is past 85 % of its budget, spare chunks in its memory that no list took for ten seconds go: at most 32 of them and 32 MB a second, and 32 MB always stay. Where the card has room, or its use is not known, nothing goes (`keep_freed` as before). They are freed on the reaper thread by default, not under the submission lock. Exceptions: with `LEONIDA_BURY_LAG=0` and no submission running they are dropped at once on the sweeping thread; with `LEONIDA_REAPER=0`, or the reaper's line full, on the thread that buries. `LEONIDA_SPARE_IDLE=0`: as before. ### Tested Series X, 2560x1440, game gate 300 s in the world, counted from a minute in; the second half of each run for the memory. With it / with `LEONIDA_SPARE_IDLE=0`: | | ray tracing (`-HardwareRT`), 2 pairs | no ray tracing, 1 pair | |---|---|---| | Card, MB | 8,499, 8,450 / 8,763, 8,745 | 8,189 / 8,228 | | Title's textures alive, MB | 1,730, 1,691 / 1,514, 1,468 | 2,970 / 2,728 | | Frames a second, median | 20.95, 21.34 / 21.50, 21.12 | 23.47 / 23.36 | | Frames a second, 5th percentile | 12.2, 12.2 / 12.0, 12.1 | 14.0 / 14.3 | | Stutters of 250 ms, of 1 s and more (all runs) | 57, 11 / 57, 11 | 5, 3 / 6, 1 | These are from a local build of `main` `8877be372` with #3495, #3496 and switches that were off. This branch's own build on `main` `d9b618f10` alone (without #3495 and #3496), one `-HardwareRT` pair, with it / with `LEONIDA_SPARE_IDLE=0`. The card is over its budget of 9.2 GB in both runs: | | with it | without | |---|---|---| | Card, MB (second half) | 9,528 | 9,949 | | Title's textures alive, MB (second half) | 1,435 | 1,465 | | Frames a second, median (5th percentile) | 21.2 (11.2) | 19.9 (10.8) | | Stutters of 250 ms, of 1 s and more | 30, 2 | 40, 8 | The textures gain nothing there; where the room went was not looked at. The first table is from a build with #3495 and #3496, where the card was at 8.2 to 8.8 GB. One pair says little about speed and stutters. - The speed of one pair each says little: without it 21.50 and 21.12, with it 20.95 and 21.34. No claim about stutters from driving; nobody drove it yet, the route was the same in every run. - Earlier forms freed on the submitting thread; five pairs had 38 stutters of 1 s and more against 27. It is not told apart from chance, but that is why the freeing moved. - The churn guard (more than 1,000 chunks made in 10 s) tripped in none of the runs. - Unit tests `the_spare_pool_lets_the_idle_go` and `a_large_spare_does_not_keep_the_others`: fail with the rule taken out, pass with it. All unit tests of the branch: 799 passed, 0 failed, 59 ignored (leonida-gpu, diagnostics, mimalloc). - Two review passes by a separate agent before this; what they found is fixed (chunks in use could go, many releases under the lock, a large chunk in front kept the others, a card whose use is not known). - Not tested: other cards. Where the card has room the rule does nothing. 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)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
First-time contributor

Independent local verification of this change (I changed no code).

  • Head fed52a4b (Merge main), merge base 0036195a. Both new tests are absent on the base: git grep -F the_spare_pool_lets_the_idle_go 0036195a -- d3d12/crates/leonida-gpu/src/host.rs -> exit 1 (same for a_large_spare_does_not_keep_the_others).
  • On the PR head, private CARGO_TARGET_DIR, -- --exact: host::scratch_card_tests::the_spare_pool_lets_the_idle_go -> 1 passed / 851 filtered; host::scratch_card_tests::a_large_spare_does_not_keep_the_others -> 1 passed / 851 filtered. No is_none() device gate in the added lines.
  • git diff --check 0036195a fed52a4b -> clean. python -I scripts/check_no_game_data.py on host.rs, pool.rs, docs/findings.md and docs/switches.md -> clean.

GPUs tested: none (CPU-only pool/spare accounting on synthetic values). Driver: n/a. No game data, assets or extracted shaders were used or attached.

AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.

Independent local verification of this change (I changed no code). - Head `fed52a4b` (`Merge main`), merge base `0036195a`. Both new tests are absent on the base: `git grep -F the_spare_pool_lets_the_idle_go 0036195a -- d3d12/crates/leonida-gpu/src/host.rs` -> exit 1 (same for `a_large_spare_does_not_keep_the_others`). - On the PR head, private `CARGO_TARGET_DIR`, `-- --exact`: `host::scratch_card_tests::the_spare_pool_lets_the_idle_go` -> 1 passed / 851 filtered; `host::scratch_card_tests::a_large_spare_does_not_keep_the_others` -> 1 passed / 851 filtered. No `is_none()` device gate in the added lines. - `git diff --check 0036195a fed52a4b` -> clean. `python -I scripts/check_no_game_data.py` on host.rs, pool.rs, docs/findings.md and docs/switches.md -> clean. GPUs tested: none (CPU-only pool/spare accounting on synthetic values). Driver: n/a. No game data, assets or extracted shaders were used or attached. AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.
First-time contributor

Test report from another machine (I changed no code). Not a review of the code.

  • Head fed52a4b4 merged onto main 93b9d90a2: clean merge.
  • RTX 3060 Ti 8 GB, driver 610.88, Intel i7-13700KF, Windows 11, 32 GB RAM.
  • cargo test -p leonida-gpu --lib --locked -- --test-threads=1, 4 runs: 3 passed (792 passed, 0 failed), 1 failed.
  • The new tests (the_spare_pool_lets_the_idle_go, a_large_spare_does_not_keep_the_others) passed in all 4 runs.
  • The failing run: pool::small::tests::small_buffers_are_placed_in_blocks_and_used_again_on_the_card failed (small.rs:562, unwrap on None); 791 passed. I could not reproduce it in the 3 runs after.
  • About the machine: every run was inside a Windows job object capped at 6 GB of committed memory, and the PC had 6 to 7 GB of free commit. main 93b9d90a2 passed the same command 4 of 4 times (790 passed), 3 of them under the same cap.
  • That test has failed on main on this PC before, once, while Windows was short on commit, so I read this failure as the machine's and not this change's. I cannot prove it.
  • Not run: the real-card (--ignored) tests, clippy, the clean-room check, any in-game run.

GPUs tested: RTX 3060 Ti 8 GB, driver 610.88. No game files were used.

AI-assisted: yes (Claude Code, Claude Fable 5.2; verification only).

Test report from another machine (I changed no code). Not a review of the code. - Head `fed52a4b4` merged onto `main` `93b9d90a2`: clean merge. - RTX 3060 Ti 8 GB, driver 610.88, Intel i7-13700KF, Windows 11, 32 GB RAM. - `cargo test -p leonida-gpu --lib --locked -- --test-threads=1`, 4 runs: **3 passed (792 passed, 0 failed), 1 failed**. - The new tests (`the_spare_pool_lets_the_idle_go`, `a_large_spare_does_not_keep_the_others`) passed in all 4 runs. - The failing run: `pool::small::tests::small_buffers_are_placed_in_blocks_and_used_again_on_the_card` failed (`small.rs:562`, `unwrap` on `None`); 791 passed. I could not reproduce it in the 3 runs after. - About the machine: every run was inside a Windows job object capped at 6 GB of committed memory, and the PC had 6 to 7 GB of free commit. `main` `93b9d90a2` passed the same command 4 of 4 times (790 passed), 3 of them under the same cap. - That test has failed on `main` on this PC before, once, while Windows was short on commit, so I read this failure as the machine's and not this change's. I cannot prove it. - Not run: the real-card (`--ignored`) tests, clippy, the clean-room check, any in-game run. GPUs tested: RTX 3060 Ti 8 GB, driver 610.88. No game files were used. AI-assisted: yes (Claude Code, Claude Fable 5.2; verification only).
Sign in to join this conversation.
No description provided.