WIP: [pr-performance][memory] DARNER_LAND_LEAVE: listed ranges stay on the card when shader writes are declared, not compared there #310

Draft
Yorivel wants to merge 1 commit from Yorivel/Darner:pr/land-leave-declared into main
First-time contributor

Refs #287

Draft. Update below: a city run, but with #274 merged in too, so its copy-back figures are not this change's alone. A city run with this change alone is next.

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: DARNER_LAND_LEAVE leaves listed ranges only at the landing (host.rs, the relay's fetch plan): the card has already hashed and compared them by then. In my A/B (below, "v0") it left 185 pieces, 5.6 MB a frame, and landed pieces fell by 42 %, but the relay's time and the frame times did not improve.

Shadow::shader_writes now cuts a declared shader write by the list (land::leave::split). The parts inside a listed range are left on the card the way DARNER_WC_NO_BACK leaves write-combined memory: note_batch_write, mark_written, leaves, and no deferred write, so the card neither hashes nor compares them. The parts outside go on as before (the rest of shader_writes, moved into Shadow::shader_writes_back unchanged). The landing's check stays, for pieces flagged another way. The frame-rate line of the switch also gives the MB of declared writes left. With the switch unset nothing changes: leave::on() is false and shader_writes calls shader_writes_back with the whole write, as before.

The risks are DARNER_WC_NO_BACK's, for the listed ranges only: the title reading there sees old bytes, and a page the CPU writes goes up whole and takes back the shaders' bytes in it. Hence the list comes from a DARNER_LAND_READS census (#300 names the code places that touch landed pages): ranges the title's code never touched.

How it was tested

  • Tested revision: the same commit on f3840d7 with #185 merged, PGO build; the gates on this branch (on main f3840d7).

  • Commands and results: cargo test -p darner-gpu --lib land::leave (2 tests, one new: a write cut by the listed ranges); the gates below.

  • Changes a default: no (only with DARNER_LAND_LEAVE set, off by default).

  • A/B result: RTX 4090, the same save, 10 min each, DARNER_UNIFIED_STATS=1; A = no list (two runs), v0 = main's landing-time leave, v1 = this change; the same list of 15 ranges, 21 MiB, made from two censuses that agreed on 21 of 22 MiB.

    A (runs 1, 4) v0, at the landing v1, this change
    wc to copy back per frame, median 159 / 149 MB 147 MB 76 MB
    relay "landing in all" per frame, median 11.9 / 15.0 ms 17.4 ms 8.2 ms
    frames over 50 ms, whole run 2.8 / 5.5 % 10.2 % 0.9 %
    frames over 50 ms, 3,000-5,000 draws 0.9 / 1.1 % 2.5 % 0.4 %
    frames over 50 ms, 5,000-7,000 draws 3.7 / 3.6 % 6.0 % 2.1 %
  • Gates run on 53d43eb: the asset policy and gates 1 and 2 (both clippy runs) pass. Gate 3: every crate passes except darner-gpu's library tests, where one watch:: test (watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs) failed in the full parallel run. This change touches no watch code; the same tests fail by chance on main too (see #300's description, and #224, #261).

  • Gameplay: RTX 4090, i9-14900K, Series X, 1440p, DLSS Quality, DLSS frame generation 2x, hardware RT. No visual faults seen with the list, in either run.

  • Hardware dependence: the mechanism is general; the list is per PC until shown otherwise (the census's addresses held between my runs, other PCs untested).

  • Coverage gaps: one run per variant. The v1 run had lighter scenes (no samples above 9,000 draws, five at 7,000-9,000), so its whole-run figures gain from that; the per-band rows are the fairer comparison. Driving into the city at its end it stuttered with the texture queue at 10,300 slots, 2,939 waiting for memory; heavy scenes are the next run.

Update: a run into the city

Same settings and list, 10 min, into the city from about the second minute. The build had this change plus #274 (and #283, which does nothing with Reflex off), so the copy-back figures are the two together.

By draw band A (runs 1, 4): copy-back ms / frames > 50 ms this + #274: copy-back ms / frames > 50 ms
5,000-7,000 9.9, 10.2 / 3.7, 3.6 % 6.0 / 4.7 %
7,000-9,000 12.0, 10.9 / 6.9, 11.6 % 6.8 / 7.7 %
9,000 and more 16.2, 13.1 / 9.5, 10.1 % 8.2 / 14.0 %

Copy-back about halves in every band, the city's too; wc to copy back per frame, median, 94 MB (A 159 / 149). No visual faults seen.

Frames over 50 ms did not fall in the city, and per minute they follow the texture queue, not the landing:

Minute texture slots queued waiting for their memory frames > 50 ms
13:54 2,810 227 0.4 %
13:50 11,621 2,774 7.8 %
13:56 11,330 2,748 16.7 %
13:58 9,245 2,577 11.8 %

So the city's remaining stutter looks like texture streaming waiting for room, which this change does not touch. The A runs spent less time in the city, so the per-band comparison is the fairest there is, not an exact one.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none (#300 helps make a list; not needed to build or use this)

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #300 (the census's code places). No open PR changes land/leave.rs. #37, #214, #218, #219 and #221 change shadow.rs elsewhere; #221's hunk lies next to shader_writes, and a trial merge of it with this branch has no conflict.
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

Refs #287 **Draft.** Update below: a city run, but with #274 merged in too, so its copy-back figures are not this change's alone. A city run with this change alone is next. ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: `DARNER_LAND_LEAVE` leaves listed ranges only at the landing (`host.rs`, the relay's fetch plan): the card has already hashed and compared them by then. In my A/B (below, "v0") it left 185 pieces, 5.6 MB a frame, and landed pieces fell by 42 %, but the relay's time and the frame times did not improve. `Shadow::shader_writes` now cuts a declared shader write by the list (`land::leave::split`). The parts inside a listed range are left on the card the way `DARNER_WC_NO_BACK` leaves write-combined memory: `note_batch_write`, `mark_written`, `leaves`, and no deferred write, so the card neither hashes nor compares them. The parts outside go on as before (the rest of `shader_writes`, moved into `Shadow::shader_writes_back` unchanged). The landing's check stays, for pieces flagged another way. The frame-rate line of the switch also gives the MB of declared writes left. With the switch unset nothing changes: `leave::on()` is false and `shader_writes` calls `shader_writes_back` with the whole write, as before. The risks are `DARNER_WC_NO_BACK`'s, for the listed ranges only: the title reading there sees old bytes, and a page the CPU writes goes up whole and takes back the shaders' bytes in it. Hence the list comes from a `DARNER_LAND_READS` census (#300 names the code places that touch landed pages): ranges the title's code never touched. ## How it was tested - Tested revision: the same commit on `f3840d7` with #185 merged, PGO build; the gates on this branch (on `main` `f3840d7`). - Commands and results: `cargo test -p darner-gpu --lib land::leave` (2 tests, one new: a write cut by the listed ranges); the gates below. - Changes a default: no (only with `DARNER_LAND_LEAVE` set, off by default). - A/B result: RTX 4090, the same save, 10 min each, `DARNER_UNIFIED_STATS=1`; A = no list (two runs), v0 = main's landing-time leave, v1 = this change; the same list of 15 ranges, 21 MiB, made from two censuses that agreed on 21 of 22 MiB. | | A (runs 1, 4) | v0, at the landing | v1, this change | |---|---|---|---| | wc to copy back per frame, median | 159 / 149 MB | 147 MB | 76 MB | | relay "landing in all" per frame, median | 11.9 / 15.0 ms | 17.4 ms | 8.2 ms | | frames over 50 ms, whole run | 2.8 / 5.5 % | 10.2 % | 0.9 % | | frames over 50 ms, 3,000-5,000 draws | 0.9 / 1.1 % | 2.5 % | 0.4 % | | frames over 50 ms, 5,000-7,000 draws | 3.7 / 3.6 % | 6.0 % | 2.1 % | - Gates run on `53d43eb`: the asset policy and gates 1 and 2 (both clippy runs) pass. Gate 3: every crate passes except `darner-gpu`'s library tests, where one `watch::` test (`watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs`) failed in the full parallel run. This change touches no `watch` code; the same tests fail by chance on `main` too (see #300's description, and #224, #261). - Gameplay: RTX 4090, i9-14900K, Series X, 1440p, DLSS Quality, DLSS frame generation 2x, hardware RT. No visual faults seen with the list, in either run. - Hardware dependence: the mechanism is general; the list is per PC until shown otherwise (the census's addresses held between my runs, other PCs untested). - Coverage gaps: one run per variant. The v1 run had lighter scenes (no samples above 9,000 draws, five at 7,000-9,000), so its whole-run figures gain from that; the per-band rows are the fairer comparison. Driving into the city at its end it stuttered with the texture queue at 10,300 slots, 2,939 waiting for memory; heavy scenes are the next run. ## Update: a run into the city Same settings and list, 10 min, into the city from about the second minute. The build had **this change plus #274** (and #283, which does nothing with Reflex off), so the copy-back figures are the two together. | By draw band | A (runs 1, 4): copy-back ms / frames > 50 ms | this + #274: copy-back ms / frames > 50 ms | |---|---|---| | 5,000-7,000 | 9.9, 10.2 / 3.7, 3.6 % | 6.0 / 4.7 % | | 7,000-9,000 | 12.0, 10.9 / 6.9, 11.6 % | 6.8 / 7.7 % | | 9,000 and more | 16.2, 13.1 / 9.5, 10.1 % | 8.2 / 14.0 % | Copy-back about halves in every band, the city's too; wc to copy back per frame, median, 94 MB (A 159 / 149). No visual faults seen. Frames over 50 ms did not fall in the city, and per minute they follow the texture queue, not the landing: | Minute | texture slots queued | waiting for their memory | frames > 50 ms | |---|---|---|---| | 13:54 | 2,810 | 227 | 0.4 % | | 13:50 | 11,621 | 2,774 | 7.8 % | | 13:56 | 11,330 | 2,748 | 16.7 % | | 13:58 | 9,245 | 2,577 | 11.8 % | So the city's remaining stutter looks like texture streaming waiting for room, which this change does not touch. The A runs spent less time in the city, so the per-band comparison is the fairest there is, not an exact one. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none (#300 helps make a list; not needed to build or use this) ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #300 (the census's code places). No open PR changes `land/leave.rs`. #37, #214, #218, #219 and #221 change `shadow.rs` elsewhere; #221's hunk lies next to `shader_writes`, and a trial merge of it with this branch has no conflict. - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Shadow::shader_writes cuts a declared write by the list (land::leave::split):
the parts inside are left on the card the way DARNER_WC_NO_BACK leaves
write-combined memory, so the card neither hashes nor compares them; the rest
goes on as before (Shadow::shader_writes_back). The landing's check stays for
pieces flagged another way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
First-time contributor

Amazing🎉

Amazing🎉
First-time contributor

@TrustNo1 review this

@TrustNo1 review this
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/land-leave-declared:Yorivel-pr/land-leave-declared'
git switch 'Yorivel-pr/land-leave-declared'

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.

git switch 'main'
git merge --no-ff 'Yorivel-pr/land-leave-declared'
git switch 'Yorivel-pr/land-leave-declared'
git rebase 'main'
git switch 'main'
git merge --ff-only 'Yorivel-pr/land-leave-declared'
git switch 'Yorivel-pr/land-leave-declared'
git rebase 'main'
git switch 'main'
git merge --no-ff 'Yorivel-pr/land-leave-declared'
git switch 'main'
git merge --squash 'Yorivel-pr/land-leave-declared'
git switch 'main'
git merge --ff-only 'Yorivel-pr/land-leave-declared'
git switch 'main'
git merge 'Yorivel-pr/land-leave-declared'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
TrustNo1/Darner!310
No description provided.