[pr-diagnostics][memory] DARNER_LAND_READS: name the code places that touch landed pages first #300

Open
Yorivel wants to merge 2 commits from Yorivel/Darner:pr/land-read-places into main
First-time contributor

Refs #287

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: DARNER_LAND_READS=1 counts first touches of landed pages by our code and by other code, but says nowhere which code. In my runs "by ours" was 85 % of the watched pages a frame with no way to tell which path, and the title's copies through vcruntime140's memcpy all showed up as one place in the C runtime.

Each first touch is now noted by the code's place (module and offset, through readwatch::module_of, made pub(crate) for this):

  • the title's places are logged the first time each is seen;
  • with the census on the frame-rate line, the most frequent places since the start, ours (top 24) and other code's (top 12) apart;
  • a touch inside vcruntime140's memcpy/memset is put on its caller (they are leaves, so the caller's return address is at the stack pointer), and logged as "read through VCRUNTIME140.dll+0x...".

The handler only adds a map entry per fault (one lock); nothing else changes, and nothing runs with the switch off. README's row for the switch says so.

With it, "ours" turned out to be darner_safe_copy_at alone (named from the PDB with llvm-symbolizer), that is, the next landing's merge reading title memory before it stores: those pages were not read by anything between two landings. Results in #287.

How it was tested

  • Tested revision: this commit's change, on f3840d7 with #185 merged, release build (gates below are on this branch, 8792ecf).
  • Commands and results: two DARNER_LAND_READS=1 runs in the open world. Places logged as above; first touches over a whole run: title 1.1 %, our next landing 85.2 %, landed in again untouched 13.7 %.
  • Changes a default: no (only with DARNER_LAND_READS=1, off by default).
  • A/B result: not applicable, diagnostic switch, off by default.
  • Gates run on 8792ecf: gates 1 and 2 (both clippy runs) pass. Gate 3: every crate passes except darner-gpu's library tests, which are flaky in the full parallel run, and not from this change (it touches no watch code): on this branch 1 of 3 full runs passed, the other two each failed a different watch:: test (tests::ask_once_by_res_splits_reservations_without_refusals, watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs), both of which pass when run alone (5 of 5); on main f3840d7 the same suite did not finish: one test kept a core busy for over 15 minutes and I stopped it. #224 and #261 look at stalls and chance failures in these tests.
  • Gameplay: RTX 4090, i9-14900K, Series X, 1440p, DLSS Quality, DLSS frame generation 2x, hardware RT.
  • Hardware dependence: none expected.
  • Coverage gaps: one of the two runs ended in a crash that is in the census itself, not in this change: the title read a page the census had made no-access, after shadow had moved host copies of 8-byte buffers on that page into the card's memory ("a buffer's host copy is in the card's memory"). The census no longer held the page, so its handler passed the fault on. Details in #287; not fixed here.

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

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none touch land/reads.rs or readwatch.rs; #58 and #37 change land.rs, which this does not.
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

Refs #287 ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: `DARNER_LAND_READS=1` counts first touches of landed pages by our code and by other code, but says nowhere which code. In my runs "by ours" was 85 % of the watched pages a frame with no way to tell which path, and the title's copies through `vcruntime140`'s `memcpy` all showed up as one place in the C runtime. Each first touch is now noted by the code's place (module and offset, through `readwatch::module_of`, made `pub(crate)` for this): - the title's places are logged the first time each is seen; - with the census on the frame-rate line, the most frequent places since the start, ours (top 24) and other code's (top 12) apart; - a touch inside `vcruntime140`'s `memcpy`/`memset` is put on its caller (they are leaves, so the caller's return address is at the stack pointer), and logged as "read through VCRUNTIME140.dll+0x...". The handler only adds a map entry per fault (one lock); nothing else changes, and nothing runs with the switch off. README's row for the switch says so. With it, "ours" turned out to be `darner_safe_copy_at` alone (named from the PDB with `llvm-symbolizer`), that is, the next landing's merge reading title memory before it stores: those pages were not read by anything between two landings. Results in #287. ## How it was tested - Tested revision: this commit's change, on `f3840d7` with #185 merged, release build (gates below are on this branch, `8792ecf`). - Commands and results: two `DARNER_LAND_READS=1` runs in the open world. Places logged as above; first touches over a whole run: title 1.1 %, our next landing 85.2 %, landed in again untouched 13.7 %. - Changes a default: no (only with `DARNER_LAND_READS=1`, off by default). - A/B result: not applicable, diagnostic switch, off by default. - Gates run on `8792ecf`: gates 1 and 2 (both clippy runs) pass. Gate 3: every crate passes except `darner-gpu`'s library tests, which are flaky in the full parallel run, and not from this change (it touches no `watch` code): on this branch 1 of 3 full runs passed, the other two each failed a different `watch::` test (`tests::ask_once_by_res_splits_reservations_without_refusals`, `watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs`), both of which pass when run alone (5 of 5); on `main` `f3840d7` the same suite did not finish: one test kept a core busy for over 15 minutes and I stopped it. #224 and #261 look at stalls and chance failures in these tests. - Gameplay: RTX 4090, i9-14900K, Series X, 1440p, DLSS Quality, DLSS frame generation 2x, hardware RT. - Hardware dependence: none expected. - Coverage gaps: one of the two runs ended in a crash that is in the census itself, not in this change: the title read a page the census had made no-access, after `shadow` had moved host copies of 8-byte buffers on that page into the card's memory ("a buffer's host copy is in the card's memory"). The census no longer held the page, so its handler passed the fault on. Details in #287; not fixed here. ## 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 ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none touch `land/reads.rs` or `readwatch.rs`; #58 and #37 change `land.rs`, which this does not. - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Each first touch of a landed page is also noted by the code's place (module
and offset, through readwatch::module_of): the title's places are logged the
first time each is seen, and the most frequent places, ours and other code's
apart, with the census on the frame-rate line. A touch inside vcruntime140's
memcpy/memset (leaves: the caller's return address is at the stack pointer)
is put on its caller, so the title's copies and ours are told apart.

Refs #287

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

Independent Windows build, gate, and code-read review of 8792ecf7562c (full head 8792ecf7562c72a25e4007918e9735ecbf8669f8), based on main f3840d73d3504c30218debfbc8795b9225447317. Not run in-game.

Environment

  • Windows 11 Pro 26H2 (build 26300.10075), Intel Core i9-14900K, NVIDIA RTX A2000 12GB (driver 621.47), Rust 1.98.1 (x86_64-pc-windows-msvc), MSVC 19.44.35230.

Measured results

  • Gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings): PASS.
  • Gate 2 (cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASS.
  • cargo xtask policy: PASS (asset policy: 555 files ok).
  • cargo test --locked -p darner-gpu --lib land::reads::tests: PASS (1 passed; 0 failed; 0 ignored; 1836 filtered out).
  • cargo test --locked -p darner-gpu --lib readwatch::: PASS (2 passed; 0 failed; 0 ignored; 1835 filtered out).
  • Full workspace tests and gameplay were not run in this review. The in-game measurements and census crash described in the PR body were not independently reproduced.

Code-read audit

  • DARNER_LAND_READS=1 remains opt-in (land/reads.rs:46); the landing path calls watch only for pages collected while that option is enabled (land.rs:672-739). The new site map keys code address, access type, and intercepted runtime address, and accumulates counts plus the first touched MiB (land/reads.rs:85, 276-277).
  • The caller-attribution path is constrained to the vcruntime140.dll image range and otherwise retains the faulting instruction address (land/reads.rs:213-220, 256-264). module_of resolves the module filename used in formatted locations (readwatch.rs:318-340); the focused landing and readwatch tests pass.

Finding

  • CHANGES NEEDED — The first-touch log labels every non-Darner address as title code. log_sites defines “ours” only as the Darner image range (land/reads.rs:350-353) and emits "title code touched" for every site outside that range (land/reads.rs:360-366). This includes any other loaded DLL or runtime caller, not just the game executable. That can give a false source attribution in the diagnostic this PR adds. Either identify the title executable separately for this message, or label the category as non-Darner/process code; keep the existing broader “other code than ours” wording where that is what the count represents.

Verdict: CHANGES NEEDED.

AI-assisted: yes (GitHub Copilot, Auto mode).

Independent Windows build, gate, and code-read review of `8792ecf7562c` (full head `8792ecf7562c72a25e4007918e9735ecbf8669f8`), based on `main` `f3840d73d3504c30218debfbc8795b9225447317`. Not run in-game. ### Environment - Windows 11 Pro 26H2 (build 26300.10075), Intel Core i9-14900K, NVIDIA RTX A2000 12GB (driver 621.47), Rust 1.98.1 (`x86_64-pc-windows-msvc`), MSVC 19.44.35230. ### Measured results - Gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`): **PASS**. - Gate 2 (`cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`): **PASS**. - `cargo xtask policy`: **PASS** (`asset policy: 555 files ok`). - `cargo test --locked -p darner-gpu --lib land::reads::tests`: **PASS** (`1 passed; 0 failed; 0 ignored; 1836 filtered out`). - `cargo test --locked -p darner-gpu --lib readwatch::`: **PASS** (`2 passed; 0 failed; 0 ignored; 1835 filtered out`). - Full workspace tests and gameplay were not run in this review. The in-game measurements and census crash described in the PR body were not independently reproduced. ### Code-read audit - `DARNER_LAND_READS=1` remains opt-in (`land/reads.rs:46`); the landing path calls `watch` only for pages collected while that option is enabled (`land.rs:672-739`). The new site map keys code address, access type, and intercepted runtime address, and accumulates counts plus the first touched MiB (`land/reads.rs:85, 276-277`). - The caller-attribution path is constrained to the `vcruntime140.dll` image range and otherwise retains the faulting instruction address (`land/reads.rs:213-220, 256-264`). `module_of` resolves the module filename used in formatted locations (`readwatch.rs:318-340`); the focused landing and readwatch tests pass. ### Finding - **CHANGES NEEDED — The first-touch log labels every non-Darner address as title code.** `log_sites` defines “ours” only as the Darner image range (`land/reads.rs:350-353`) and emits `"title code touched"` for every site outside that range (`land/reads.rs:360-366`). This includes any other loaded DLL or runtime caller, not just the game executable. That can give a false source attribution in the diagnostic this PR adds. Either identify the title executable separately for this message, or label the category as non-Darner/process code; keep the existing broader “other code than ours” wording where that is what the count represents. **Verdict: CHANGES NEEDED.** AI-assisted: yes (GitHub Copilot, Auto mode).
Author
First-time contributor

Thanks for the review. You're right: everything outside Darner's image was labelled "title code".

Fixed in 0a950b7: the first-touch line now reads "code other than ours touched a page a landing put in, first time from here", matching the count it belongs to, and the doc comment and README row say that "other code" is any module but Darner's (the game's own image is darner-image-*.dll, its DLLs, or the C runtime when no caller is found). Each place was already named by its module in the code field, so nothing else changes.

Gates on 0a950b7: cargo xtask policy (555 files ok), gate 1 and gate 2 pass; cargo test --locked -p darner-gpu --lib land::reads (1 passed) and readwatch:: (2 passed). The full workspace suite was not rerun for this wording change.

Thanks for the review. You're right: everything outside Darner's image was labelled "title code". Fixed in `0a950b7`: the first-touch line now reads "code other than ours touched a page a landing put in, first time from here", matching the count it belongs to, and the doc comment and README row say that "other code" is any module but Darner's (the game's own image is `darner-image-*.dll`, its DLLs, or the C runtime when no caller is found). Each place was already named by its module in the `code` field, so nothing else changes. Gates on `0a950b7`: `cargo xtask policy` (555 files ok), gate 1 and gate 2 pass; `cargo test --locked -p darner-gpu --lib land::reads` (1 passed) and `readwatch::` (2 passed). The full workspace suite was not rerun for this wording change.
This pull request can be merged automatically.
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 'pr/land-read-places:Yorivel-pr/land-read-places'
git switch 'Yorivel-pr/land-read-places'

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-read-places'
git switch 'Yorivel-pr/land-read-places'
git rebase 'main'
git switch 'main'
git merge --ff-only 'Yorivel-pr/land-read-places'
git switch 'Yorivel-pr/land-read-places'
git rebase 'main'
git switch 'main'
git merge --no-ff 'Yorivel-pr/land-read-places'
git switch 'main'
git merge --squash 'Yorivel-pr/land-read-places'
git switch 'main'
git merge --ff-only 'Yorivel-pr/land-read-places'
git switch 'main'
git merge 'Yorivel-pr/land-read-places'
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!300
No description provided.