runtime: keep the physical-page slab bookkeeping in a portable header and report slab counts #1749
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1756"
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-24T18:09:37Z.
Splits the slab bookkeeping of the physical pages out of
xmem_mapped_pages.cppinto a header that needs no Windows, and reports it. Refs #1199 (item 2 stays open).Changes
src/xmem_slab_slots.h(standard C++17 only):x2w_xmem::SlabSlots<Handle>keeps the slabs, how many slots of the newest slab were handed out, and an ordered set of released slots. Released slots are reused lowest first. A new slab of 4096 slots is opened through a callback; if the callback fails nothing changes, and if recording the slab throws the new slab is discarded and the exception continues. Counters: slabs, slots in use, slots free.src/xmem_mapped_pages.cppuses it. The Windows calls (CreateFileMappingW,MapViewOfFile) are unchanged and stay in this file. One difference: released slots are ordered by (slab creation order, offset) instead of (handle value, offset); the handle order was arbitrary, this one is deterministic.x2w_xmem_page_statsis unchanged. New exportx2w_xmem_slab_stats(slabs, in_use, free), listed inxmem_shim.defas @16.tests/xmem_slab_slots_check.cpp(registered asxmem_slab_slots): a fake slab factory checks the 4096-slot boundary, lowest-first adjacent reuse, reuse preferring the older slab, freeing everything keeping the slabs open, a failing factory leaving state unchanged (first and second slab), unwinding a fresh slot (including slot 0 of a new slab), refused invalid releases, and exact counters throughout.tests/xmem_page_stats_check.pyalso checks the slab counters through grant, map, unmap, release and a page-token write.docs/startup-runtime.mdexplains the units and updates the build/test snippet (xmem_slab_slots_check+xmem_slab_slots). The heartbeat label (sections) is left alone; the doc says what it counts now.Not claimed
This does not reduce commit. A slab is still charged in full when it is created (default
CreateFileMappingWflags, untouched) and closed only at process exit, so freeing pages returns slots, not commit. The new counters are the before/after units for later work.Verified (Windows Server 2025, MSVC 14.44.35207, Debug & Release
/O2)--preset dev): built all 42 direct targets (xmem_shim,xmem_shim_test_controls,xmem_slab_slots_check,startup_stub_*,xgameruntime_*,cpu_*);ctest --preset dev22/22 passed (30.31s), includingxmem_slab_slots(0.03s),xmem_page_stats(0.08s),xmem_shim_mapped_pages(0.18s),xmem_shim_page_runs(9.92s),startup_heartbeat_commit(30.21s)./O2(--preset release): built all 42 direct targets;ctest --preset release22/22 passed (30.28s), includingxmem_slab_slots(0.02s),xmem_page_stats(0.10s),xmem_shim_mapped_pages(0.22s),xmem_shim_page_runs(9.74s),startup_heartbeat_commit(30.20s). Coversctest --preset release -R "^(xmem_slab_slots|xmem_page_stats)$" -V.src/xmem_slab_slots.h(slots_in_use()ignoringfree_.size()): killed by bothxmem_slab_slotsandxmem_page_stats((1, 2, 4094)vs expected(1, 0, 4096)).src/xmem_mapped_pages.cpp(free_pages()skippingmemory.slots.release(...)): killed byxmem_page_stats((1, 2, 4094)vs expected(1, 0, 4096)).Verified (Linux)
g++ -std=c++17 -O2 -Wall -Wextra -Wpedantic -Wconversion -fsanitize=address,undefined -Isrc tests/xmem_slab_slots_check.cpp: no warnings, passes.git diff --check origin/main...HEAD,tests/docs_links_check.py,tests/bidi_controls_check.py: pass.git merge-tree --write-tree origin/main HEAD: clean, no conflicts withmain.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T19:02:42Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
dca7a4aℹ️ 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.