d3d12-gpu: name the module behind a missed heap view record, and count copies carrying a tag off the slot grid #3429

Code

Clone this repository

Checkout

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

git fetch -u  "d3d12/heap-view-writers:KelboLive-d3d12/heap-view-writers"
git switch "KelboLive-d3d12/heap-view-writers"
Open
leonida/mandy
KelboLive wants to merge 4 commits from KelboLive/mandy:d3d12/heap-view-writers into main

This pull request can be merged automatically.

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request can be merged automatically.
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/heap-view-writers:KelboLive-d3d12/heap-view-writers'
git switch 'KelboLive-d3d12/heap-view-writers'
First-time contributor

What/why

#3394: view records written into the title's shader-visible heap by code that no store or copy tells of show up only when the port_descriptors fallback reaches their page, so textures flicker black until then. The log names the code that last faulted on the record's 64 KiB block, but writers outside the title printed as bare addresses, so most of the reported misses were unreadable:

title+0x4d9f264 1725, 0x7ffa7f19c1d3 (not the title's) 1432, 0x7ff9537b0000 (not the title's) 1063, ...

This change makes those writers identifiable, and answers the other open question in the report: whether the title's memcpy/memmove copies into the heap carry view records at all (the wrap marks 0 while it sees ~5,758 copies a frame into the heap).

Changes

  • port_descriptors.rs
    • writer_name(rip): title+0x… inside the title image, otherwise the module's file name and offset (GetModuleHandleExW(FROM_ADDRESS) + GetModuleFileNameW), cached per address (a module lookup once per distinct rip, capped at 4,096 entries; misses are rare). Falls back to the raw address only when no module holds it.
    • contains_view_tag(bytes): when a copy into the heap marks no slot, scan up to 256 bytes of the copied range for VIEW_TAG at any 4-byte offset, so the line says whether the copy carried a view record off the heap's 32-byte slot grid. Counted as the third COPIES cell and printed after the existing two.
    • titlewrite::place is now pub(crate) and reused rather than duplicated.
  • The copy scan is bounded (256 bytes per such copy) and only runs when the slot loop marked nothing, so the hot path is unchanged.

Tests

  • an_outside_writer_is_named_by_its_module: an address in the test binary must come back as <file>+0x…, not a bare address and not (module not found).
  • a_view_record_is_found_off_the_slot_grid: a tag at a non-slot offset is found; zeros and a 2-byte buffer are not.
  • cargo test -p leonida-gpu --lib -- --test-threads=1: 732 passed, 0 failed, 59 ignored
  • cargo check --workspace --all-targets --locked, cargo clippy -p leonida-gpu --all-targets --locked: clean
  • python -I scripts/check_no_game_data.py: exit 0; tools/d3d12_switches.py --check: exit 0; git diff --check: clean

Phase 2 measured (by @Otavmacedo, n=1)

RTX 3070 8 GB, 427 s in the world, LEONIDA_PORT_DESCRIPTORS=1. The six biggest writers since the start are four sites in VCRUNTIME140.dll's copy routine and two addresses in one page that no module holds; no title site is among them after the first minute. The new copy-tag counter was 0 in every line, 450 lines long, while the wrap saw a median 3,087 title memcpy/memmove calls into the heap a frame that marked 0 records.

So on this evidence the title's own copies are not the source of the missed view records, and the fallback's writer is most likely code that calls the C runtime's copy — leonida.exe itself imports VCRUNTIME140.dll. Follow-up lead (not in this PR): take one frame up from those sites to name the caller.

Item: D3D12-UNWATCHED-HEAP-VIEW-WRITERS, claimed in #3312 (comment 25200). Depends on: none.
AI-assisted: DeepSeek V4.1 Flash (OpenCode); a separate read-only reviewer will audit the diff before merge.

## What/why #3394: view records written into the title's shader-visible heap by code that no store or copy tells of show up only when the `port_descriptors` fallback reaches their page, so textures flicker black until then. The log names the code that last faulted on the record's 64 KiB block, but **writers outside the title printed as bare addresses**, so most of the reported misses were unreadable: ```text title+0x4d9f264 1725, 0x7ffa7f19c1d3 (not the title's) 1432, 0x7ff9537b0000 (not the title's) 1063, ... ``` This change makes those writers identifiable, and answers the other open question in the report: whether the title's `memcpy`/`memmove` copies into the heap carry view records at all (the wrap marks 0 while it sees ~5,758 copies a frame into the heap). ## Changes - `port_descriptors.rs` - `writer_name(rip)`: `title+0x…` inside the title image, otherwise the module's file name and offset (`GetModuleHandleExW(FROM_ADDRESS)` + `GetModuleFileNameW`), cached per address (a module lookup once per distinct rip, capped at 4,096 entries; misses are rare). Falls back to the raw address only when no module holds it. - `contains_view_tag(bytes)`: when a copy into the heap marks **no** slot, scan up to 256 bytes of the copied range for `VIEW_TAG` at any 4-byte offset, so the line says whether the copy carried a view record **off the heap's 32-byte slot grid**. Counted as the third `COPIES` cell and printed after the existing two. - `titlewrite::place` is now `pub(crate)` and reused rather than duplicated. - The copy scan is bounded (256 bytes per such copy) and only runs when the slot loop marked nothing, so the hot path is unchanged. ## Tests - `an_outside_writer_is_named_by_its_module`: an address in the test binary must come back as `<file>+0x…`, not a bare address and not `(module not found)`. - `a_view_record_is_found_off_the_slot_grid`: a tag at a non-slot offset is found; zeros and a 2-byte buffer are not. - `cargo test -p leonida-gpu --lib -- --test-threads=1`: **732 passed, 0 failed, 59 ignored** - `cargo check --workspace --all-targets --locked`, `cargo clippy -p leonida-gpu --all-targets --locked`: clean - `python -I scripts/check_no_game_data.py`: exit 0; `tools/d3d12_switches.py --check`: exit 0; `git diff --check`: clean ## Phase 2 measured (by @Otavmacedo, n=1) RTX 3070 8 GB, 427 s in the world, `LEONIDA_PORT_DESCRIPTORS=1`. The six biggest writers since the start are **four sites in `VCRUNTIME140.dll`'s copy routine** and two addresses in one page that no module holds; no title site is among them after the first minute. The new copy-tag counter was **0 in every line, 450 lines long**, while the wrap saw a median 3,087 title `memcpy`/`memmove` calls into the heap a frame that marked 0 records. So on this evidence the title's own copies are not the source of the missed view records, and the fallback's writer is most likely code that calls the C runtime's copy — `leonida.exe` itself imports `VCRUNTIME140.dll`. Follow-up lead (not in this PR): take one frame up from those sites to name the caller. Item: `D3D12-UNWATCHED-HEAP-VIEW-WRITERS`, claimed in #3312 (comment 25200). Depends on: none. AI-assisted: DeepSeek V4.1 Flash (OpenCode); a separate read-only reviewer will audit the diff before merge.
Author
First-time contributor

Phase 2 is open for anyone with a free Windows + NVIDIA machine. The change is ready to merge on its own (diagnostics only); this is the run that turns the new names into an answer.

Recipe:

  1. Build main + this branch with the diagnostics features (scripts/build-nvidia.ps1, diag profile).
  2. Run the usual Series X 1440p recipe (docs/running.md, scripts/play-d3d12.ps1) with LEONIDA_PORT_DESCRIPTORS=1 and -HardwareRT if you normally use it.
  3. Play from a save for ~7 minutes on foot and driving (the issue says it happens within the first minute).

Then post here, as text only:

  • the renderer port 2 … per frame line, and its since the start: … their writers: list — writers outside the title now read module.dll+0x…;
  • the new field after the two copy counts: how many copies into the heap carried a view's tag off the slot grid.

No screenshots, log lines, paths or addresses from the game in the repo, per the rules.

**Phase 2 is open for anyone with a free Windows + NVIDIA machine.** The change is ready to merge on its own (diagnostics only); this is the run that turns the new names into an answer. Recipe: 1. Build `main` + this branch with the diagnostics features (`scripts/build-nvidia.ps1`, diag profile). 2. Run the usual Series X 1440p recipe (`docs/running.md`, `scripts/play-d3d12.ps1`) with `LEONIDA_PORT_DESCRIPTORS=1` and `-HardwareRT` if you normally use it. 3. Play from a save for ~7 minutes on foot **and** driving (the issue says it happens within the first minute). Then post here, as text only: - the `renderer port 2 … per frame` line, and its `since the start: … their writers:` list — writers outside the title now read `module.dll+0x…`; - the new field after the two copy counts: how many copies into the heap **carried a view's tag off the slot grid**. No screenshots, log lines, paths or addresses from the game in the repo, per the rules.
Author
First-time contributor

Self-review pass done (a second, read-only reviewer audited the diff). Head is now 35dcd8f3d.

Addressed:

  • The counter is pinned in the existing copy test: the first copy marks slots 40/42 (COPIES[1] == 2, no tag off-grid), the second puts its tag 8 bytes into slot 100 (COPIES[2] == 1). Reverting only the scan now fails the test.
  • Wording: the log says {copies2} of those copies carried a view's tag off the slot grid (it counts copies, not records), and the doc says it is a lower bound (a copy with an aligned tag too, or a tag past 256 bytes, is not counted).
  • Module doc: dropped the unmeasured "most misses come from outside the title"; the observable fact is that outside writers used to print as bare addresses.
  • Naming test: now asserts the module's file name is the test executable's and pins writer_name(0).
  • Failed module lookups are not cached, so a transient loader-lock failure can resolve later.
  • contains_view_tag is a plain helper over a bounded slice; the copy path still only scans when it marked no slot, and that scan happens on the common copy (bounded at 256 bytes, no allocation).

cargo test -p leonida-gpu --lib -- --test-threads=1: 732 passed; clippy, workspace check, switch check and no-game-data clean.

Phase 2 (the 7-minute run) remains open for someone with a free machine, per the comment below.

Self-review pass done (a second, read-only reviewer audited the diff). Head is now `35dcd8f3d`. Addressed: - **The counter is pinned in the existing copy test**: the first copy marks slots 40/42 (`COPIES[1] == 2`, no tag off-grid), the second puts its tag 8 bytes into slot 100 (`COPIES[2] == 1`). Reverting only the scan now fails the test. - **Wording**: the log says `{copies2} of those copies carried a view's tag off the slot grid` (it counts copies, not records), and the doc says it is a **lower bound** (a copy with an aligned tag too, or a tag past 256 bytes, is not counted). - **Module doc**: dropped the unmeasured "most misses come from outside the title"; the observable fact is that outside writers used to print as bare addresses. - **Naming test**: now asserts the module's file name is the test executable's and pins `writer_name(0)`. - **Failed module lookups are not cached**, so a transient loader-lock failure can resolve later. - `contains_view_tag` is a plain helper over a bounded slice; the copy path still only scans when it marked no slot, and that scan happens on the common copy (bounded at 256 bytes, no allocation). `cargo test -p leonida-gpu --lib -- --test-threads=1`: **732 passed**; clippy, workspace check, switch check and no-game-data clean. Phase 2 (the 7-minute run) remains open for someone with a free machine, per the comment below.
First-time contributor

TAKEN | Otavmacedo | ETA 2026-12-04 08:00 UTC | AI-assisted: Claude Code (Claude Opus 5.5)

Phase 2, after the A/B this machine is running now (#3198). NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11, 16 GB RAM.

  • BUILD: current main 863694e28 + this PR's head 35dcd8f3d (clean merge), diagnostics,dlss,mimalloc.
  • RECIPE, with deviations from yours, said up front: on this 8 GB card the Series X / 1440p recipe does not last (video memory over its budget, device losses, #2821), so it is d3d12/docs/windows-memory.md's 8 GB profile (-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30) + LEONIDA_PORT_DESCRIPTORS=1, no -HardwareRT. One gate run from a save, mods/gate_driver in roam mode (it walks a loop on foot; no driving), 420 s in the world.
  • SEND BACK: the renderer port 2 … per frame line, its since the start: … their writers: list with the module names, and the new off-grid copy count, as text only, plus whether the misses show at this resolution at all.
TAKEN | Otavmacedo | ETA 2026-12-04 08:00 UTC | AI-assisted: Claude Code (Claude Opus 5.5) Phase 2, after the A/B this machine is running now (#3198). NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11, 16 GB RAM. - BUILD: current `main` 863694e28 + this PR's head 35dcd8f3d (clean merge), `diagnostics,dlss,mimalloc`. - RECIPE, with deviations from yours, said up front: on this 8 GB card the Series X / 1440p recipe does not last (video memory over its budget, device losses, #2821), so it is d3d12/docs/windows-memory.md's 8 GB profile (`-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`) + `LEONIDA_PORT_DESCRIPTORS=1`, no `-HardwareRT`. One gate run from a save, `mods/gate_driver` in `roam` mode (it walks a loop on foot; no driving), 420 s in the world. - SEND BACK: the `renderer port 2 … per frame` line, its `since the start: … their writers:` list with the module names, and the new off-grid copy count, as text only, plus whether the misses show at this resolution at all.
First-time contributor

DONE | phase 2, taken above | AI-assisted: Claude Code (Claude Opus 5.5)

Short: with the names in, the six biggest writers since the start, at the end of the run, are four sites in the C runtime's copy routine (VCRUNTIME140.dll) and two addresses in one page that no module holds; no title site is among them. The new counter stayed at 0 for the whole run: no copy into the heap carried a view's tag off the slot grid. One run (n=1).

  • BUILD: current main 863694e28 + this PR's head 35dcd8f3d (clean merge), diagnostics,dlss,mimalloc.
  • MACHINE: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11 Pro 26200, Ryzen 7 5700X, 16 GB RAM.
  • RECIPE (deviations said in the TAKEN): -SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30, no -HardwareRT; one gate run from a save, mods/gate_driver in roam mode (walking a loop on foot, no driving), 427 s in the world, gate PASS, median 22.3 fps. LEONIDA_PORT_DESCRIPTORS=1 was set, but note that d3d12/scripts/play-nvidia.ps1 already sets it by default (its settings table, line 293), so every launcher run has the fallback on.

The last renderer port 2 … per frame line, its counts only (no game addresses):

since the start: 340,900,418 slots told (35,409,513 by our calls), 119,382 pages looked at, 9,606 view records missed;
their writers: VCRUNTIME140.dll+0x1c1d7 1649, <address, module not found> 1019, VCRUNTIME140.dll+0x1c283 913,
<address, module not found> 840, VCRUNTIME140.dll+0x1c2d8 676, VCRUNTIME140.dll+0x1c2bc 604

What the run says, each tagged:

  • MEASURED (n=1): the misses do show at this resolution and on foot: 9,606 in 427 s (median 1.07 view records a frame that no store told of, at most 10.2), against about 4,100 in a 7-minute run on an RTX 4070 and 11,972 in another run in the issue.
  • MEASURED (450 per-frame lines): the copy counter is 0 in every line, while the wrap saw a median of 3,087 title memcpy/memmove calls into the heap a frame (at most 13,677), marking 0 records. So the title's own copies do not carry view records, on or off the grid, at least within the first 256 bytes the scan looks at.
  • MEASURED: the writers list is the top six since the start (empty for the first 60 lines, six entries after). Over the run, the VCRUNTIME140.dll entries that reached it were six offsets: +0x1c1d7, +0x1c1d3, +0x1c283, +0x1c2bc, +0x1c2d8 and +0x1bc5b. The writers with no module were four addresses, all in one 4 KB page (at its start and 0x80, 0xc0 and 0x100 into it); this PR's lookup finds no loaded image there (allocated code, or a mapping). The title's own sites were in the top six only early on, with counts up to 13 (the site #3394 lists first among them), and were passed by the runtime's and the unnamed writers' counts after that.
  • ASSUMED: VCRUNTIME140.dll at those offsets is its memcpy/memmove body; who calls it is not shown. The title's copies go through the wrap and mark nothing, so the caller is likely code that links the C runtime dynamically and writes into the heap pages the title then reads: leonida.exe itself imports VCRUNTIME140.dll (READ in its import table), so the runtime's own copies are one candidate. A return address taken one frame up from those sites (the module that called memcpy) would settle it; I did not try that. Which copy of the DLL was loaded was not checked.

No screenshots, log files, paths or game addresses posted, per the rules.

GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M.

DONE | phase 2, taken above | AI-assisted: Claude Code (Claude Opus 5.5) **Short: with the names in, the six biggest writers since the start, at the end of the run, are four sites in the C runtime's copy routine (`VCRUNTIME140.dll`) and two addresses in one page that no module holds; no title site is among them. The new counter stayed at 0 for the whole run: no copy into the heap carried a view's tag off the slot grid.** One run (n=1). - BUILD: current `main` 863694e28 + this PR's head 35dcd8f3d (clean merge), `diagnostics,dlss,mimalloc`. - MACHINE: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.47, Windows 11 Pro 26200, Ryzen 7 5700X, 16 GB RAM. - RECIPE (deviations said in the TAKEN): `-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`, no `-HardwareRT`; one gate run from a save, `mods/gate_driver` in `roam` mode (walking a loop on foot, no driving), 427 s in the world, gate PASS, median 22.3 fps. `LEONIDA_PORT_DESCRIPTORS=1` was set, but note that `d3d12/scripts/play-nvidia.ps1` already sets it by default (its settings table, line 293), so every launcher run has the fallback on. The last `renderer port 2 … per frame` line, its counts only (no game addresses): ```text since the start: 340,900,418 slots told (35,409,513 by our calls), 119,382 pages looked at, 9,606 view records missed; their writers: VCRUNTIME140.dll+0x1c1d7 1649, <address, module not found> 1019, VCRUNTIME140.dll+0x1c283 913, <address, module not found> 840, VCRUNTIME140.dll+0x1c2d8 676, VCRUNTIME140.dll+0x1c2bc 604 ``` What the run says, each tagged: - MEASURED (n=1): the misses do show at this resolution and on foot: 9,606 in 427 s (median 1.07 view records a frame that no store told of, at most 10.2), against about 4,100 in a 7-minute run on an RTX 4070 and 11,972 in another run in the issue. - MEASURED (450 per-frame lines): the copy counter is 0 in every line, while the wrap saw a median of 3,087 title `memcpy`/`memmove` calls into the heap a frame (at most 13,677), marking 0 records. So the title's own copies do not carry view records, on or off the grid, at least within the first 256 bytes the scan looks at. - MEASURED: the writers list is the top six since the start (empty for the first 60 lines, six entries after). Over the run, the `VCRUNTIME140.dll` entries that reached it were six offsets: +0x1c1d7, +0x1c1d3, +0x1c283, +0x1c2bc, +0x1c2d8 and +0x1bc5b. The writers with no module were four addresses, all in one 4 KB page (at its start and 0x80, 0xc0 and 0x100 into it); this PR's lookup finds no loaded image there (allocated code, or a mapping). The title's own sites were in the top six only early on, with counts up to 13 (the site #3394 lists first among them), and were passed by the runtime's and the unnamed writers' counts after that. - ASSUMED: `VCRUNTIME140.dll` at those offsets is its `memcpy`/`memmove` body; who calls it is not shown. The title's copies go through the wrap and mark nothing, so the caller is likely code that links the C runtime dynamically and writes into the heap pages the title then reads: `leonida.exe` itself imports `VCRUNTIME140.dll` (READ in its import table), so the runtime's own copies are one candidate. A return address taken one frame up from those sites (the module that called `memcpy`) would settle it; I did not try that. Which copy of the DLL was loaded was not checked. No screenshots, log files, paths or game addresses posted, per the rules. GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M.
KelboLive force-pushed d3d12/heap-view-writers from 35dcd8f3d9 to 8f9c76e4fa 2026-12-04 10:58:54 +00:00 Compare
KelboLive force-pushed d3d12/heap-view-writers from 8f9c76e4fa to 4bf10d6353 2026-12-04 12:25:27 +00:00 Compare
Author
First-time contributor

Follow-up added (head 1cd95b811): the PR now names who calls the copy, the one thing phase 2 could not show.

  • One copy in 64 into the heap walks the stack (RtlCaptureStackBackTrace) and records the first frame outside our own image, named as module.dll+0x… through the same place() used for the writers. The top four callers since the start are printed after the writers.
  • Cost is bounded: ~1 sample per 64 copies (about 47 a frame at the 3,000 copies seen), no allocation except the sampled name; the copy hot path only pays one atomic increment.
  • cargo test -p leonida-gpu --lib -- --test-threads=1: 757 passed; clippy clean for this file; switch/no-game-data/diff clean.

A run with LEONIDA_PORT_DESCRIPTORS=1 will now print, e.g. its callers: game_scarlett_master.exe+0x… 34, leonida.exe+0x… 12 — the caller of VCRUNTIME140's copy is what was missing.

Follow-up added (head `1cd95b811`): the PR now names **who calls the copy**, the one thing phase 2 could not show. - One copy in 64 into the heap walks the stack (`RtlCaptureStackBackTrace`) and records the first frame **outside our own image**, named as `module.dll+0x…` through the same `place()` used for the writers. The top four callers since the start are printed after the writers. - Cost is bounded: ~1 sample per 64 copies (about 47 a frame at the 3,000 copies seen), no allocation except the sampled name; the copy hot path only pays one atomic increment. - `cargo test -p leonida-gpu --lib -- --test-threads=1`: **757 passed**; clippy clean for this file; switch/no-game-data/diff clean. A run with `LEONIDA_PORT_DESCRIPTORS=1` will now print, e.g. `its callers: game_scarlett_master.exe+0x… 34, leonida.exe+0x… 12` — the caller of `VCRUNTIME140`'s copy is what was missing.
First-time contributor

Run of the caller sampling (head 1cd95b811) | AI-assisted: Claude Code (Claude Opus 5.5)

Short: the sampled callers of the wrapped copies into the heap are all in the title's own image (four sites), which is what the sampler is built to see; so this does not yet say who makes the VCRUNTIME140.dll writes that are missed, and my guess in the DONE above (comment 25314, the runtime's own copies as one candidate) is neither confirmed nor ruled out. One naming detail: the callers name the title's image by its mapped file (leonida-image-<hash>.dll+0x…) where the writers call the same image title+0x…. One run (n=1).

  • BUILD: this PR's head 1cd95b811 (on main 345e1cb89), diagnostics,dlss,mimalloc.
  • WHERE: built in a worktree, run from my main checkout's folder with the executable copied there (on this PC the device loss depends on the folder: #2821, comment 25546).
  • MACHINE: NVIDIA GeForce RTX 3070 8 GB, driver 621.47, Windows 11, 16 GB RAM.
  • RECIPE: as in my phase-2 run: -SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion, LEONIDA_FPS_CAP=30, LEONIDA_PORT_DESCRIPTORS=1; one gate run from a save, mods/gate_driver walking (roam), 424 s in the world, gate PASS.

The last renderer port 2 … per frame line, counts only (no game addresses):

since the start: 11,745 view records missed;
their writers: VCRUNTIME140.dll+0x1c1d7 1708, <address, module not found> 1307, <address, module not found> 1179,
VCRUNTIME140.dll+0x1c297 938, <title site> 697, <title site> 653;
of every 64 copies into the heap, one sampled, its callers: <title image site> 159808, <title image site> 151597,
<title image site> 48054, <title image site> 29434

What the run says, each tagged:

  • MEASURED (n=1): all four sampled callers are in one image, which the loader's log shows mapped at an executable's preferred base (0x140000000, the only image there): the title's own executable. READ IN CODE: the sampler sits in the wrap of the title's memcpy/memmove imports and names the first frame outside our image, so callers in the title are what it is made to find; copies that do not pass through the wrap are not sampled.
  • MEASURED: one of the callers lies a few hundred bytes from one of the title writer sites in the same image, named title+0x… in the writers and leonida-image-<hash>.dll+0x… in the callers. READ IN CODE: writer_name() checks the title image's range first and prints title+, while sample_caller() calls titlewrite::place() directly; worth giving the callers the same title check.
  • MEASURED (466 per-frame lines): the off-grid counter stayed 0 in every line again, while the wrap saw a median of 3,056 title copies into the heap a frame, marking 0 records; and the C runtime's copy is still the top writer of missed records.
  • ASSUMED: put together, it looks as if copies the title makes through VCRUNTIME140.dll write view records that neither the wrap's marking nor the off-grid scan catch. The counters alone do not say why (records past the first 256 bytes the scan looks at, or copies that do not pass through the wrap, would both fit). Taking the caller at the fault that names the writer (the one the writers list records as VCRUNTIME140.dll), rather than inside the wrap, would tell those two apart, and would answer the runtime-or-title question for the missed writes.
  • MEASURED: this time two title sites were also in the writers' top six (they were passed by the end in phase 2), next to the two VCRUNTIME140.dll sites and the two addresses in the page no module holds.

No screenshots, log files, paths or game addresses posted, per the rules.

GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M.

The figures were recomputed from the run records by a separate read-only agent before posting.

Run of the caller sampling (head 1cd95b811) | AI-assisted: Claude Code (Claude Opus 5.5) **Short: the sampled callers of the wrapped copies into the heap are all in the title's own image (four sites), which is what the sampler is built to see; so this does not yet say who makes the `VCRUNTIME140.dll` writes that are missed, and my guess in the DONE above (comment 25314, the runtime's own copies as one candidate) is neither confirmed nor ruled out. One naming detail: the callers name the title's image by its mapped file (`leonida-image-<hash>.dll+0x…`) where the writers call the same image `title+0x…`.** One run (n=1). - BUILD: this PR's head 1cd95b811 (on `main` 345e1cb89), `diagnostics,dlss,mimalloc`. - WHERE: built in a worktree, run from my main checkout's folder with the executable copied there (on this PC the device loss depends on the folder: #2821, comment 25546). - MACHINE: NVIDIA GeForce RTX 3070 8 GB, driver 621.47, Windows 11, 16 GB RAM. - RECIPE: as in my phase-2 run: `-SeriesS -Resolution 540 -NoFrameGen -NoSmoothMotion`, `LEONIDA_FPS_CAP=30`, `LEONIDA_PORT_DESCRIPTORS=1`; one gate run from a save, `mods/gate_driver` walking (`roam`), 424 s in the world, gate PASS. The last `renderer port 2 … per frame` line, counts only (no game addresses): ```text since the start: 11,745 view records missed; their writers: VCRUNTIME140.dll+0x1c1d7 1708, <address, module not found> 1307, <address, module not found> 1179, VCRUNTIME140.dll+0x1c297 938, <title site> 697, <title site> 653; of every 64 copies into the heap, one sampled, its callers: <title image site> 159808, <title image site> 151597, <title image site> 48054, <title image site> 29434 ``` What the run says, each tagged: - MEASURED (n=1): all four sampled callers are in one image, which the loader's log shows mapped at an executable's preferred base (0x140000000, the only image there): the title's own executable. READ IN CODE: the sampler sits in the wrap of the title's `memcpy`/`memmove` imports and names the first frame outside our image, so callers in the title are what it is made to find; copies that do not pass through the wrap are not sampled. - MEASURED: one of the callers lies a few hundred bytes from one of the title writer sites in the same image, named `title+0x…` in the writers and `leonida-image-<hash>.dll+0x…` in the callers. READ IN CODE: `writer_name()` checks the title image's range first and prints `title+`, while `sample_caller()` calls `titlewrite::place()` directly; worth giving the callers the same title check. - MEASURED (466 per-frame lines): the off-grid counter stayed 0 in every line again, while the wrap saw a median of 3,056 title copies into the heap a frame, marking 0 records; and the C runtime's copy is still the top writer of missed records. - ASSUMED: put together, it looks as if copies the title makes through `VCRUNTIME140.dll` write view records that neither the wrap's marking nor the off-grid scan catch. The counters alone do not say why (records past the first 256 bytes the scan looks at, or copies that do not pass through the wrap, would both fit). Taking the caller at the fault that names the writer (the one the writers list records as `VCRUNTIME140.dll`), rather than inside the wrap, would tell those two apart, and would answer the runtime-or-title question for the missed writes. - MEASURED: this time two title sites were also in the writers' top six (they were passed by the end in phase 2), next to the two `VCRUNTIME140.dll` sites and the two addresses in the page no module holds. No screenshots, log files, paths or game addresses posted, per the rules. GPUs tested: NVIDIA GeForce RTX 3070 8 GB, 621.47, Windows 11, profile M. The figures were recomputed from the run records by a separate read-only agent before posting.
sample_caller() formatted the frame itself as file+offset, so a caller in the title's image printed as leonida-image-<hash>.dll+0x... while the writers list printed the same image as title+0x.... It still skips frames in our own image, then names the chosen frame with writer_name(): title+0x... in the title's image, module.dll+0x... elsewhere. A frame with no fault on its block, or one whose module will not resolve, is skipped rather than counted. The one-in-64 sampling and sampling-time-only naming are unchanged.
Author
First-time contributor

Naming fixed in b083012b3, from the run's note: sample_caller now names the chosen frame with writer_name, so a caller in the title's image reads title+0x… like the writers do, instead of leonida-image-<hash>.dll+0x…. Our own frames are still skipped, and frames with no resolvable module are skipped rather than counted.

757 serial tests, clippy clean for the file, no-game-data and diff clean. A re-run would now show its callers: title+0x… and make the two lists directly comparable.

The run's larger point stands: this samples the caller inside the wrap, so it only sees copies that go through the wrapped imports. The caller at the guard fault that names a VCRUNTIME140 writer would separate "title copies through the CRT" from "copies that bypass the wrap" — that is a separate probe, not in this PR.

Naming fixed in `b083012b3`, from the run's note: `sample_caller` now names the chosen frame with `writer_name`, so a caller in the title's image reads **`title+0x…`** like the writers do, instead of `leonida-image-<hash>.dll+0x…`. Our own frames are still skipped, and frames with no resolvable module are skipped rather than counted. 757 serial tests, clippy clean for the file, no-game-data and diff clean. A re-run would now show `its callers: title+0x…` and make the two lists directly comparable. The run's larger point stands: this samples the caller **inside the wrap**, so it only sees copies that go through the wrapped imports. The caller **at the guard fault that names a `VCRUNTIME140` writer** would separate "title copies through the CRT" from "copies that bypass the wrap" — that is a separate probe, not in this PR.
KelboLive force-pushed d3d12/heap-view-writers from b083012b32 to 4ac8778758 2026-12-04 13:37:50 +00:00 Compare
KelboLive force-pushed d3d12/heap-view-writers from 4ac8778758 to f5e4a9fca3 2026-12-04 15:10:26 +00:00 Compare
Author
First-time contributor

Rebased onto main 44c480a5f (head f5e4a9fca). No conflicts (upstream touched only list.rs). Re-ran: 760 passed, 0 failed, 60 ignored.

Rebased onto `main` `44c480a5f` (head `f5e4a9fca`). No conflicts (upstream touched only `list.rs`). Re-ran: 760 passed, 0 failed, 60 ignored.
Author
First-time contributor

Thanks - both runs are exactly the evidence this needed, and the second one points at the follow-up that already exists.

  • The top writers being VCRUNTIME140.dll copies with no title site confirms the wrap cannot see them (they do not pass through it).
  • The probe you describe is #3467 (stacked on this PR): it takes the caller at the guard fault itself, validates [Rsp] with VirtualQuery, and prints writer (caller) - so a VCRUNTIME140.dll entry will carry the return address of whoever called it, title or not. That is the run that distinguishes "records past the first 256 bytes" from "copies that do not pass through the wrap".
  • The naming inconsistency you found is real and is fixed in the same commit: sample_caller() will use writer_name() too, so the title prints title+0x... in both lists.

No run needed from you for this PR; #3467 is where the next one would be useful if you have the time.

Thanks - both runs are exactly the evidence this needed, and the second one points at the follow-up that already exists. - The top writers being `VCRUNTIME140.dll` copies with no title site confirms the wrap cannot see them (they do not pass through it). - **The probe you describe is #3467** (stacked on this PR): it takes the caller at the guard fault itself, validates `[Rsp]` with `VirtualQuery`, and prints `writer (caller)` - so a `VCRUNTIME140.dll` entry will carry the return address of whoever called it, title or not. That is the run that distinguishes "records past the first 256 bytes" from "copies that do not pass through the wrap". - The naming inconsistency you found is real and is fixed in the same commit: `sample_caller()` will use `writer_name()` too, so the title prints `title+0x...` in both lists. No run needed from you for this PR; #3467 is where the next one would be useful if you have the time.
KelboLive force-pushed d3d12/heap-view-writers from f5e4a9fca3 to e842ed15a9 2026-12-04 15:56:58 +00:00 Compare
Author
First-time contributor

Replayed onto main bba262b94 (head e842ed15a). No conflicts. Read the merged port_descriptors.rs against upstream #3477's plan_parts/each_page_run: no clash - parts are never indexed by slot/handle and the writers block stays heap-relative. Re-ran: 779 passed, 0 failed, 60 ignored.

Replayed onto `main` `bba262b94` (head `e842ed15a`). No conflicts. Read the merged `port_descriptors.rs` against upstream #3477's `plan_parts`/`each_page_run`: **no clash** - parts are never indexed by slot/handle and the writers block stays heap-relative. Re-ran: 779 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from e842ed15a9 to cdf83ebf11 2026-12-04 16:15:48 +00:00 Compare
Author
First-time contributor

Replayed onto main e1be896b2 (head cdf83ebf1). No conflicts. 779 passed, 0 failed, 60 ignored.

Replayed onto `main` `e1be896b2` (head `cdf83ebf1`). No conflicts. 779 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from cdf83ebf11 to b37c53ba59 2026-12-04 16:32:24 +00:00 Compare
Author
First-time contributor

Replayed onto main 00e245be5 (head b37c53ba5). No conflicts. 789 passed, 0 failed, 60 ignored.

Replayed onto `main` `00e245be5` (head `b37c53ba5`). No conflicts. 789 passed, 0 failed, 60 ignored.
Contributor

A synthetic descriptor fixture could generate a known mix of aligned copies, copies carrying a tag off the slot grid, and writes from two dummy module classes. Include more off-grid candidates than the scan cap. Report the missed-record count, the writer-class counts, and all three copy counters for the same window. Compare the observed off-grid count with the injected total to check the lower-bound interpretation.

AI-assisted with OpenAI Codex.

A synthetic descriptor fixture could generate a known mix of aligned copies, copies carrying a tag off the slot grid, and writes from two dummy module classes. Include more off-grid candidates than the scan cap. Report the missed-record count, the writer-class counts, and all three copy counters for the same window. Compare the observed off-grid count with the injected total to check the lower-bound interpretation. AI-assisted with OpenAI Codex.
KelboLive force-pushed d3d12/heap-view-writers from b37c53ba59 to 359832fb1b 2026-12-04 17:15:05 +00:00 Compare
Author
First-time contributor

Replayed onto main f22b9fa64 (head 359832fb1). No conflicts. 792 passed, 0 failed, 60 ignored.

Replayed onto `main` `f22b9fa64` (head `359832fb1`). No conflicts. 792 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from 359832fb1b to d20591eb72 2026-12-04 18:30:14 +00:00 Compare
Author
First-time contributor

Replayed onto main 6491bc1a1 (head d20591eb7), crossing #3486's ab.rs/copystat.rs/descriptor/host.rs changes. No conflicts; switch page ok. 792 passed, 0 failed, 60 ignored.

Replayed onto `main` `6491bc1a1` (head `d20591eb7`), crossing #3486's `ab.rs`/`copystat.rs`/`descriptor/host.rs` changes. No conflicts; switch page ok. 792 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from d20591eb72 to cd2cba27f8 2026-12-04 18:44:06 +00:00 Compare
Author
First-time contributor

Replayed onto main 6b0498d37 (head cd2cba27f). No conflicts. 792 passed, 0 failed, 60 ignored.

Replayed onto `main` `6b0498d37` (head `cd2cba27f`). No conflicts. 792 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from cd2cba27f8 to 578a94485f 2026-12-04 20:52:47 +00:00 Compare
Author
First-time contributor

Replayed onto main 0036195a7 (head 578a94485). No conflicts. 792 passed, 0 failed, 60 ignored.

Replayed onto `main` `0036195a7` (head `578a94485`). No conflicts. 792 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from 578a94485f to 5fd5290e9f 2026-12-04 23:20:13 +00:00 Compare
Author
First-time contributor

Replayed onto main f4b0404e9 (head 5fd5290e9). No conflicts. 792 passed, 0 failed, 60 ignored.

Replayed onto `main` `f4b0404e9` (head `5fd5290e9`). No conflicts. 792 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from 5fd5290e9f to 0cb08a7357 2026-12-05 05:34:34 +00:00 Compare
Author
First-time contributor

Replayed onto main 93b9d90a2 (head 0cb08a735). No conflicts. 792 passed, 0 failed, 60 ignored.

Replayed onto `main` `93b9d90a2` (head `0cb08a735`). No conflicts. 792 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from 0cb08a7357 to 400c011e17 2026-12-05 08:44:18 +00:00 Compare
Author
First-time contributor

Replayed onto main c5355dd25 (head 400c011e1). No conflicts. 793 passed, 0 failed, 60 ignored (upstream's new descriptor test included).

Replayed onto `main` `c5355dd25` (head `400c011e1`). No conflicts. 793 passed, 0 failed, 60 ignored (upstream's new descriptor test included).
KelboLive force-pushed d3d12/heap-view-writers from 400c011e17 to 8e6be47bdf 2026-12-05 08:53:03 +00:00 Compare
Author
First-time contributor

Replayed onto main e1b0248c1 (head 8e6be47bd). No conflicts. 793 passed, 0 failed, 60 ignored.

Replayed onto `main` `e1b0248c1` (head `8e6be47bd`). No conflicts. 793 passed, 0 failed, 60 ignored.
KelboLive force-pushed d3d12/heap-view-writers from 8e6be47bdf to 0f323d5331 2026-12-05 09:59:34 +00:00 Compare
Author
First-time contributor

Replayed onto main d99bb4d7a (head 0f323d533). No conflicts. 796 passed, 0 failed, 60 ignored (includes upstream's new descriptor tests).

Replayed onto `main` `d99bb4d7a` (head `0f323d533`). No conflicts. 796 passed, 0 failed, 60 ignored (includes upstream's new descriptor tests).
Sign in to join this conversation.
No description provided.