audio: commit the stand-in APU heap on demand #2767
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!2767
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2767/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?
@triggered02 on GitHub · 2026-11-26 06:52 UTC · original
triggered02:audio/apu-heap-on-demand-commit→main· +225 −26 · 3 files · 1 commits · merged 2026-11-26 06:56 UTCReserves the stand-in APU heap up front and commits/decommits 4 KiB pages on demand, eliminating up to ~457 MiB of unused commit charge at
ApuCreateHeaptime. Refs #1199.What changed
src/startup_stubs/acphal.cpp:ApuCreateHeapnow callsVirtualAlloc(nullptr, bytes, MEM_RESERVE, PAGE_READWRITE)so 0 bytes are committed until an allocation takes space in the heap.heap_takecomputes the 4 KiB page-aligned span[page_begin, page_end)covering[block_start, block_end)and commits it viaVirtualAlloc(..., MEM_COMMIT, PAGE_READWRITE)underheap_lockbefore modifyingextents[],extent_count, orhigh_water. A commit failure leaves the free list untouched and returnsnullptr(E_OUTOFMEMORYinApuAlloc/AcpHalAllocateShapeContexts). Reused blocks belowhigh_waterremain zero-filled (memset(0)), including partial boundary pages.heap_givecoalesces adjacent free extents into[free_begin, free_end)underheap_lock, computes the strictly interior 4 KiB-aligned span[ceil_page(free_begin), floor_page(free_end)), and callsVirtualFree(..., MEM_DECOMMIT)only whendecommit_end > decommit_begin, so shared boundary pages held by live adjacent allocations remain committed and untouched.tests/startup_acphal_apu_free.cpp: preserves all existing unit, concurrency, mapping, shape-context, and trap checks, and adds--commit-check(spawned in a fresh childAcpHal.dllinstance with a 64 MiBApuCreateHeap) verifying:MEM_RESERVE+ ~0PagefileUsageafterApuCreateHeap; page-scoped commit onApuAlloc; safe shared boundary page across adjacent live blocks; interiorMEM_DECOMMIT+PagefileUsagedrop onApuFreewithout disturbing the live neighbor; zero-fill on reallocation; and cleanE_OUTOFMEMORYrollback under aJOB_OBJECT_LIMIT_PROCESS_MEMORYcap.docs/startup-runtime.md: updated theAPU heap stand-insection for on-demand commit/decommit and the expanded fixture.Verified (
4a024bc3on currentmain)Fail-first mutants (temporary, reverted on
45f3da5d):MEM_COMMIT | MEM_RESERVEinApuCreateHeap: failsstartup_acphal_apu_free(FAIL: PagefileUsage stays near 0 growth after 64 MiB ApuCreateHeap,FAIL: entire 64 MiB heap starts in MEM_RESERVE state, plus 6 more checks).MEM_DECOMMITinheap_give: failsstartup_acphal_apu_free(FAIL: interior pages of freed first sub-block return to MEM_RESERVE,FAIL: PagefileUsage drops after interior freed pages are decommitted).floor_page(free_begin)..ceil_page(free_end)instead of strictly interior pages: failsstartup_acphal_apu_freewithException: SegFaulton shared sub-page allocations andFAIL: shared boundary page stays MEM_COMMIT while adjacent second block is live.NOT established
ApuCreateHeapreservation directly without first callingApuAllocorAcpHalAllocateShapeContexts(any such access would fault on a reserved page).--commit-check, theJOB_OBJECT_LIMIT_PROCESS_MEMORYcommit-failure sub-check executes whenAssignProcessToJobObjectsucceeds (it ran and passed locally; inside a restricted nested job without breakaway that sub-check is skipped rather than failing).AI-assisted.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 06:53 UTC · original
Codex Review Summary: ❌ Failed
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.4a024bcℹ️ 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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-26 06:53 UTC · original
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.
@tedin7 on GitHub · 2026-11-26 06:56 UTC · original · reviewed
Review of head
4a024bc3(comment only).Checked:
acphal.cpp: the heap is reserved only;heap_takecommits the 4 KiB page span of the new block before touching the extent table, and a failed commit leaves the free list unchanged (clean E_OUTOFMEMORY).heap_givedecommits only the strictly interior pages of the coalesced free extent, so boundary pages shared with live neighbors stay committed. Reused blocks belowhigh_waterare still zeroed. Re-committing an already committed page does not clear it, so shared boundary pages are safe.tests/startup_acphal_apu_free.cpp:--commit-checkin a fresh child covers reserve with ~0 commit, page-scoped commit, shared boundary page, interior decommit with the neighbor intact, zero-fill on reuse, and commit failure. It is wired into the existingstartup_acphal_apu_freeCTest.ApuCreateHeap.Commands run locally:
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: 23 files, 538 links okpython3 tests/bidi_controls_check.py: okctest --preset dev -R startup_acphal: 1/1 passed (startup_acphal_apu_free)ctest --preset release -R startup_acphal: 1/1 passed (startup_acphal_apu_free)No blocking findings.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-26 06:56 UTC · original
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
4a024bc35d5712a3f05b32b4a6d2aefa25741538:--preset dev):cmake --build --preset dev --target startup_acphal_apu_free startup_stub_acphal -- -j 2):1.32s(configure1.82s)ctest --preset dev -R 'startup_acphal' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.39s:startup_acphal_apu_free0.27s)/O2(--preset release):cmake --build --preset release --target startup_acphal_apu_free startup_stub_acphal -- -j 2):1.46s(configure1.82s)ctest --preset release -R 'startup_acphal' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.24s:startup_acphal_apu_free0.13s)sccache: 0/4 hits; wall11.6sAI-assisted; commands listed were executed locally.