Page residency: say which of the title's pages on the card the card is known to read #475

Manually merged
github merged 2 commits from github-bot/gh-475 into main 2026-12-04 17:31:57 +00:00 AGit
Owner

@⁠LOCKhart07 on GitHub · 2026-12-04 15:36 UTC · original
LOCKhart07:main-residency-census → main · +341 −1 · 4 files · 2 commits · merged 2026-12-04 17:30 UTC

Taken out of the reuse change of #374, where it rode along. It has nothing to do with hardware ray tracing and stands here on main alone. For the log only. No switch.

What it adds

The page residency line says how much paged title memory is on the card, not whether the card has any use for it there. A second line now sorts the pages on the card by what is known of the card's reads of them (marked as read, pointed at by address, neither), in all and for each pool of 4 MiB and more, with:

  • how each came to the card (in a pool opened there, never touched by the processor, after its mapping was watched, in a write-combined pool);
  • how many a touch of the processor's brought back down.

Diagnostics builds add a line for the title memory behind the textures the host itself writes: how much of it is on the card, under no title buffer, with nothing known to read it.

To tell these apart a page keeps one more byte of note as it moves. Nothing that moves pages reads it.

The second commit only adds parentheses where clippy's precedence lint asked for them in the new line's megabytes; the values are the same.

Measured

On one machine (x86_64-pc-windows-msvc, tests under Wine on Linux, RADV):

  • um tests: 4 passed, 1 ignored (2 new: a page on the card falls in one bucket; a page going up is told by its pool and its watch);
  • clippy (--lib --bins --tests): 51 warning lines, as on main (59 before the second commit).

Not measured

  • Not run in play on this tree, so no numbers from the lines are given.
  • The cost of the extra byte of note per page is not measured.

🤖 Generated with Claude Code

**@⁠LOCKhart07** on GitHub · 2026-12-04 15:36 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/475) `LOCKhart07:main-residency-census` → `main` · +341 −1 · 4 files · 2 commits · merged 2026-12-04 17:30 UTC Taken out of the reuse change of #374, where it rode along. It has nothing to do with hardware ray tracing and stands here on main alone. For the log only. No switch. ### What it adds The page residency line says how much paged title memory is on the card, not whether the card has any use for it there. A second line now sorts the pages on the card by what is known of the card's reads of them (marked as read, pointed at by address, neither), in all and for each pool of 4 MiB and more, with: - how each came to the card (in a pool opened there, never touched by the processor, after its mapping was watched, in a write-combined pool); - how many a touch of the processor's brought back down. Diagnostics builds add a line for the title memory behind the textures the host itself writes: how much of it is on the card, under no title buffer, with nothing known to read it. To tell these apart a page keeps one more byte of note as it moves. Nothing that moves pages reads it. The second commit only adds parentheses where clippy's precedence lint asked for them in the new line's megabytes; the values are the same. ### Measured On one machine (`x86_64-pc-windows-msvc`, tests under Wine on Linux, RADV): - `um` tests: 4 passed, 1 ignored (2 new: a page on the card falls in one bucket; a page going up is told by its pool and its watch); - clippy (`--lib --bins --tests`): 51 warning lines, as on main (59 before the second commit). ### Not measured - Not run in play on this tree, so no numbers from the lines are given. - The cost of the extra byte of note per page is not measured. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The page residency line says how much paged title memory is on the card, not whether the card has any use for it there. A second line now sorts the pages on the card by what is known of the card's reads of them (marked as read, pointed at by address, neither), in all and for each pool of 4 MiB and more, with how each came to the card (in a pool opened there, never touched by the processor, after its mapping was watched, in a write-combined pool) and how many a touch of the processor's brought back down. Diagnostics builds add a line for the title memory behind the textures the host itself writes: how much of it is on the card, under no title buffer, with nothing known to read it.

For the log alone: a page keeps one more byte of note as it moves, and nothing that moves pages reads it. No switch. Nothing to do with hardware ray tracing: taken out of the reuse change of #374, where it rode along.

Tests, under Wine: um 4 passed, 1 ignored (2 new: a page on the card falls in one bucket; a page going up is told by its pool and its watch). Not run in play on this tree, so no numbers from the lines are given, and the cost of the note is not measured.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
clippy's precedence lint on `n * K64 >> 20` in the eight places the new line computes megabytes: parentheses added, the value is the same. With it this branch has main's 51 clippy warning lines again (it had 59).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 15:38:34 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 17:09 UTC · original

Checked 345f3ae on top of main and ran the tests natively on Windows (MSVC build, not Wine) on an NVIDIA card.

  • um filter: 16 passed, 1 ignored, both new residency tests among them
  • um:: with --features diagnostics, so behind_line and host_written_memory get built: 4 passed, 1 ignored

Looks fine to me. Nothing that moves pages reads note. The tick only gets cheap additions: a load plus a one-time fetch_or per heated page (um/residency.rs:642-643), a store and a counter bump per page that goes up (870-872), and one counter per touched page that comes back down (928). These all run on the tick's own thread, next to a driver move, so the cost doesn't matter. The origin is read before RETIRED is cleared at line 882, so WATCHED can actually show up, and store(origin) clears HEATED_UP on every promotion, which gives "since it came to the card".

On locks, reads_line (1129) holds POOLS.read() while it walks every page, the same way the existing line() does at 1052, so it takes no new lock. host_written_memory (resource.rs:2795) keeps the texture table guard for the whole walk, so the raw Resource derefs are covered, and the guard drops before behind_line takes the pool copy and the shadow lookups. The two new tests cover the bucket precedence and keeping the origin bits apart from HEATED_UP. A swapped check would fail them, but they don't exercise the wiring in tick.

One nit. Clippy with --features diagnostics still reports precedence on the new behind_line (um/residency.rs:1249, 1257-1259, 1267 and on), which the second commit didn't reach because it only builds without diagnostics. The values are right, * binds before >>.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 17:09 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/475#issuecomment-7418526567) Checked 345f3ae on top of main and ran the tests natively on Windows (MSVC build, not Wine) on an NVIDIA card. - `um` filter: 16 passed, 1 ignored, both new residency tests among them - `um::` with `--features diagnostics`, so `behind_line` and `host_written_memory` get built: 4 passed, 1 ignored Looks fine to me. Nothing that moves pages reads `note`. The tick only gets cheap additions: a load plus a one-time `fetch_or` per heated page (um/residency.rs:642-643), a store and a counter bump per page that goes up (870-872), and one counter per touched page that comes back down (928). These all run on the tick's own thread, next to a driver move, so the cost doesn't matter. The origin is read before `RETIRED` is cleared at line 882, so WATCHED can actually show up, and `store(origin)` clears HEATED_UP on every promotion, which gives "since it came to the card". On locks, `reads_line` (1129) holds `POOLS.read()` while it walks every page, the same way the existing `line()` does at 1052, so it takes no new lock. `host_written_memory` (resource.rs:2795) keeps the texture table guard for the whole walk, so the raw `Resource` derefs are covered, and the guard drops before `behind_line` takes the pool copy and the shadow lookups. The two new tests cover the bucket precedence and keeping the origin bits apart from HEATED_UP. A swapped check would fail them, but they don't exercise the wiring in `tick`. One nit. Clippy with `--features diagnostics` still reports `precedence` on the new `behind_line` (um/residency.rs:1249, 1257-1259, 1267 and on), which the second commit didn't reach because it only builds without diagnostics. The values are right, `*` binds before `>>`. AI-assisted: yes
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 17:15 UTC · original · edited 2026-12-04 17:21 UTC

Fair — the body says it is taken out of the reuse change of #374, so the overlap is intentional; that is my miss, I compared diffs before reading the body.

The one thing worth a line somewhere is that both copies stay live until one of them moves: 230 of the 238 substantive lines here are the code #374 still carries, so if #374 lands first this becomes a conflict rather than a review, and if this lands first #374 needs those lines taken out. Naming that in either body is enough — no change needed here.

**@⁠Luxuride** on GitHub · 2026-12-04 17:15 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/475#issuecomment-7418661999) · edited 2026-12-04 17:21 UTC Fair — the body says it is taken out of the reuse change of #374, so the overlap is intentional; that is my miss, I compared diffs before reading the body. The one thing worth a line somewhere is that both copies stay live until one of them moves: 230 of the 238 substantive lines here are the code #374 still carries, so if #374 lands first this becomes a conflict rather than a review, and if this lands first #374 needs those lines taken out. Naming that in either body is enough — no change needed here.
github manually merged commit 2382b4c345 into main 2026-12-04 17:31:57 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.