memory: reserve mapped-page slabs and commit 64 KiB slots on first use #1958
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1958
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1958/head"
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?
@tedin7 on GitHub · 2026-11-24 22:07 UTC · original
tedin7:x2w-frontier-1199-commit→main· +174 −26 · 5 files · 3 commits · merged 2026-11-24 23:11 UTCPart of #1199
What this unblocks: startup runs on machines with limited free commit no longer pay 256 MiB of commit per physical-page slab up front, so loading gets further before
ERROR_COMMITMENT_LIMIT.Slabs are now created with
SEC_RESERVE. A 64 KiB slot is committed when its page is first mapped or written (commit_slotinsrc/xmem_mapped_pages.cpp). Pages that are granted but never used cost nothing. A slot that cannot be committed fails the call with the system error and leaves the slab bookkeeping unchanged. Freed slots stay committed, so reuse cannot fail for lack of commit.Not covered: pages that are mapped but never touched still count, and the DirectStorage worker stack overflow on
bad_alloc(item 3 of the issue) is a separate change.Verification:
git diff --stat origin/main...HEAD: 4 files (CMakeLists.txt, src/xmem_mapped_pages.cpp, src/xmem_slab_slots.h, tests/xmem_mapped_pages_commit_check.py).python -B -c "import ast; ast.parse(...)"on the new check passes;x86_64-w64-mingw32-g++ -fsyntax-only src/xmem_mapped_pages.cppreports no error in the changed lines (the MSVC-only code elsewhere in the file does not build with MinGW).x2w_pipe.py win2025 <PR> --targets xmem_shim --regex '^xmem_(mapped_pages_commit|page_stats|slab_slots|shim_mapped_pages|shim_page_runs)$'.xmem_mapped_pages_commit: maps 16 pages and asserts system commit grows by under 32 MiB (before the change it grows by about 256 MiB, one whole slab), then checks the pages are zero-filled and writable. Numbers before/after still to be filled in from the Win2025 run.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:39 UTC · original · edited 2026-11-24 22:45 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
0478a38ℹ️ 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.
@ -0,0 +62,4 @@assert mapped == base, C.get_last_error()grown = commit_bytes() - beforeprint(f"commit grew by {grown >> 20} MiB for {MAPPED_PAGES} mapped pages (a slab is {SLAB_BYTES >> 20} MiB)")assert grown < LIMIT_BYTES, f"mapping {MAPPED_PAGES} pages committed {grown >> 20} MiB: the slab is charged whole"@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:45 UTC · original
CMakeLists.txtregisters this new fixture only against the production shim, and a repository-wide search for the fixture name,commit_slot, andSEC_COMMITfound no negative-control or injected-failure run. Consequently, the fixture is never demonstrated to reject an eagerly committed slab, and the new commitment-failure path is not exercised.AGENTS.mdrequires “a negative control or failure case for a new fixture”; add an eager-commit control that must fail this assertion, or force a commitment failure and verify the returned error and accounting.AGENTS.md reference: AGENTS.md:L192-L192
Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:45 UTC · original
When mapping a subrange of a larger placeholder, the first mapping fails because the placeholder has the wrong size. If splitting succeeds but the subsequent
map()fails—for example, because Windows cannot allocate resources for the view—this unconditional reset discards the retry’s error and reports the earlier size-mismatch error.map_pagespropagates that stale error through both public mapping exports, obscuring the actual resource failure. Restore the saved error only whenVirtualFreerefuses the split; otherwise preserve the failed retry’sGetLastError().Useful? React with 👍 / 👎.
@R0Y00 on GitHub · 2026-11-24 23:07 UTC · original
Restored the mapper-owned split check and retained the actual retry error. The new source-built failure control forces ERROR_COMMITMENT_LIMIT, verifies the reserved region and slab counts remain unchanged, and retries the same grant successfully. The external placeholder shape also stays intact. Windows Release passed all six focused checks. The local commit comparison was 256 MiB on the eager-commit baseline versus 1 MiB for the same 16 mapped pages on this branch. This is a system-wide counter sample, with a separate deterministic failure control.
@R0Y00 on GitHub · 2026-11-24 22:19 UTC · original · requested changes
The slot and mapped-page fixture checks pass locally. Please keep the lazy-commit patch within the existing placeholder ownership contract. In
map_split, the new unconditionalMEM_PRESERVE_PLACEHOLDERcan split a caller-owned reservation. If that split succeeds and the retry fails, the caller receives the first map error and is left with a split reservation. Keep the registered-reservation check and preserve the actual retry error when a retry runs. Please add a source-built failure check that observes the placeholder shape withVirtualQuery. The commit test can use a reservation made through XMem or an exactly shaped caller placeholder. Please also update the upfront-commit paragraph indocs/startup-runtime.md, fix the final threePERFORMANCE_INFORMATIONfields to DWORD, and make the commit probe catch the eager-commit version without depending solely on a single system-wide delta moving in one direction. Windows placeholder semantics@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 22:45 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
0478a38640ℹ️ 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".
@R0Y00 on GitHub · 2026-11-24 23:10 UTC · original · approved these changes
Verified the scoped ownership and retry fixes and the injected commit failure on this exact head. Windows Release passed the six focused tests. The external reservation retains its shape, and a failed fresh commit preserves the counts and can be retried.