memory: reserve mapped-page slabs and commit 64 KiB slots on first use #1951
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1958"
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 tedin7 on 2026-11-24T22:07:17Z.
Part 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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T22:19:08Z.
Review: CHANGES_REQUESTED
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 semanticsImported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:45:29Z.
Review: COMMENTED
💡 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".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:39:25Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:45:29Z.
Code review location:
tests/xmem_mapped_pages_commit_check.py; line 66CMakeLists.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 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:45:29Z.
Code review location:
src/xmem_mapped_pages.cpp; line 144When 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 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T23:10:57Z.
Review: APPROVED
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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T23:07:50Z.
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.