runtime: report peak commit and physical-page sections in the startup heartbeat #1263
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1270"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T06:22:23Z.
What changed
Issue #1199 item 1: make startup runs comparable by memory spent. The DirectStorage stand-in's 10 s heartbeat now reports this process's peak and current commit charge and the number of live 64 KiB physical-page sections, and reports again when either memory value changes even while the request counters are static (so a stalled load still shows what it holds).
src/xmem_mapped_pages.cpp/src/xmem_shim.def: experimentalx2w_xmem_page_statsexport returning the number of live sections (memory.backings.size()). A section exists from a page's first use (a mapping or a page-token write) until its grant is released.src/startup_stubs/xcrdapi.cpp:memory_sample()readsPeakPagefileUsage/PagefileUsageviaGetProcessMemoryInfoand the section count throughGetProcAddresson the already-loadedxmem.dll, and the heartbeat line gains; commit peak=<MiB> current=<MiB>, live physical-page sections=<n>.The line keeps its previous fields; a missing reading prints
unknown.CMakeLists.txt: linkpsapifor the stand-in; register the two new CTest cases.docs/startup-runtime.md: short "Startup memory accounting" section.tests/xmem_page_stats_check.py,tests/startup_heartbeat_check.py: source-built checks.No allocator,
SEC_RESERVEor mapping behaviour changed; this is read-only accounting and does not overlap denn0x's experiments or PR #1264.src/startup_stubs/d3d12_xs_device.cppis untouched (the DirectStorage heartbeat is the one extended).Verification (release preset)
Before the change, both checks fail for the right reason:
After the change:
The heartbeat check maps two synthetic pages, starts the real heartbeat through
DStorageGetFactory, waits for the first 10 s report, asserts the reported section count is 2, and checks the reported peak againstGetProcessMemoryInfoin the same process.Neighbouring tests, all passing:
Not verified
No run of the title image was made (none is needed for this slice): the actual peak-commit reduction / stall comparison on a real startup run, and the section count it reports, are for a follow-up run by someone with the package. The heartbeat also starts only when the title calls
DStorageGetFactory, so its extra fields appear from the DirectStorage phase onward.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:25:31Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
46812c8ed3ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:32:08Z.
Review: COMMENTED
Dual-platform review at commit
46812c8ed3161aad20ccb92b530d0b77145b10f0:Verification
git diff --check origin/main...HEAD: passedpython -B tests/docs_links_check.py: passed (16 Markdown files, 284 links)python -B tests/bidi_controls_check.py: passed (1067 files)--preset dev):cmake --build --preset dev --target xmem_shim startup_stub_xcrdapi startup_stub_consumer -- -j 6+ctest --preset dev -R '^(xmem_page_stats|startup_heartbeat_commit|xmem_shim_mapped_pages|xmem_shim_physical_pages|startup_stubs)$' --parallel 4 --no-tests=error --output-on-failure-> 5/5 passed (10.27s:xmem_shim_mapped_pages,xmem_page_stats,startup_stubs,xmem_shim_physical_pages,startup_heartbeat_commit)/O2(--preset release):cmake --build --preset release --target xmem_shim startup_stub_xcrdapi startup_stub_consumer -- -j 6+ctest --preset release -R '^(xmem_page_stats|startup_heartbeat_commit|xmem_shim_mapped_pages|xmem_shim_physical_pages|startup_stubs)$' --parallel 4 --no-tests=error --output-on-failure-> 5/5 passed (10.21s)Code Notes
x2w_xmem_page_statsinsrc/xmem_mapped_pages.cppsafely guards against a null output pointer and readsmemory.backings.size()undermemory.mutex.memory_sample()insrc/startup_stubs/xcrdapi.cppcachesGetProcAddress(GetModuleHandleW(L"xmem.dll"), "x2w_xmem_page_stats")in a function-localstatic const— this works wheneverxmem.dllis loaded before the first heartbeat tick, and gracefully falls back tounknownotherwise.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:22:37Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
46812c8ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T06:31:54Z.
Rebased onto current
main(7a691883, was 12 commits behind) — this also retriggers CI, because the last Linux job died insideactions/checkoutwithgit ... exit code 128before any step of the job ran (GitHub network error, not this change). I cannot rerun that job from the fork side (Must have admin rights to Repository), so a fresh push was the way to get a clean run; sorry for the extra notification.Re-verified after the rebase on the
releasepreset:I also checked the two new cases fail on a pre-change build for the right reasons (missing
x2w_xmem_page_statsexport; heartbeat line without the new fields), so they are not passing vacuously.One honest limit, unchanged: the numbers above come from the source-built checks, not a title run, so this adds the observability the issue asks for (item 1) without yet providing the before/after peak-commit comparison — that needs a run and is what item 2 will be measured with.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T06:34:38Z.
First real-run numbers from this branch (the item 1 value this PR adds), run of the title to a 120 s timeout:
So it reports 102,736 live physical-page sections (~6.4 GiB at 64 KiB each) against ~7.7 GiB of peak commit, with the section count flat from 10 s on while commit keeps rising. That is exactly the comparison item 2 needs, and it is the first time these numbers are available at all — the fields appear once
DStorageGetFactoryhas run, which is the case in a title run.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T06:37:52Z.
I pushed a focused follow-up at
22709a63. The heartbeat now samples the currently loaded page provider while holding a module reference, and a change in current commit can trigger a report on its own. The source-built check observed unknown sections at 10 s, two after loading the provider at 20 s, then current commit falling from 25 to 9 MiB at the same 25 MiB peak. That check, the page-section lifetime test and the mapped-pages regression all passed in Release. The allocator and worker failure work in #1199 remain separate.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T06:25:31Z.
Code review location:
src/startup_stubs/xcrdapi.cpp; line 823If current commit changes by at least 1 MiB while request counts and the physical-section count stay fixed, but current commit remains below an already reached peak, this condition emits no new line. The reported
current=value therefore stays stale; include the current MiB value in the change check.Useful? React with 👍 / 👎.
upstream-sync referenced this pull request2026-11-25 00:04:55 +00:00