startup: start the debugged process without the debug heap #1643
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1650"
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 rm-NoobInCoding on 2026-11-24T16:03:26Z.
Change
A process that Windows creates under a debugger gets the debug heap: the loader sets the heap tail-check, free-check and parameter-validation flags (
NtGlobalFlag0x70) and the low-fragmentation heap is not used, so every allocation and free in the debugged process costs more.tools/startup/debug_launch.pycreates the title under its debugger, so every startup run paid that cost.debug_launch.pynow starts the process with_NO_DEBUG_HEAP=1unless the environment already sets_NO_DEBUG_HEAP. Setting_NO_DEBUG_HEAP=0keeps the debug heap, for example to look for heap corruption. Nothing else about the launch changes.docs/startup-runtime.mddescribes the default and the override in the Run section.No shared interface changes.
Verification
Base
874cc3fa, patch35ea852e. Windows 11 build 26300, MSVC 19.51.36260,devpreset (Debug), Python 3.11 fromout/pe-env.Result: 1/1 passed, no skips.
startup_debug_probenow prints the heap bits of its PEBNtGlobalFlag; the check requires0x0in the baseline run and0x70in a run with_NO_DEBUG_HEAP=0. The check removes any inherited_NO_DEBUG_HEAPbefore each run, so the host environment cannot decide the result.Negative control. With only
debug_launch.pyreverted to the base, the baseline assertion fails:python -B tests/docs_links_check.py: self-test passed, 16 Markdown files and 348 links.python -B tests/bidi_controls_check.py: no bidirectional controls.Evidence and follow-up
Local diagnostic runs of a console executable on the Release startup stand-ins (
tools/startup/run.ps1 -Render -FakeUser -GpuMirror -HostCpu, RTX 4070); raw logs, pointers, binaries and captures are not attached. Times are from the debugger's file and event logs and the DirectStorage heartbeat.With temporary timing around
local_applyinsrc/xmem_mapped_pages.cpp(not part of this PR), oneXMemMapPhysicalPagescall of 99,776 pages took:_NO_DEBUG_HEAP=1X2W_XMEM_SHARED_VIEWS=1About 8.9 s of each debug-heap call came after the OS mapping finished: thread samples taken during it were freeing the nodes of the call's 99,776-entry
std::map. At the run level, the first DirectStorage batch (3,254 requests) completed by the 10 s heartbeat instead of the 30 s one, and the title's first video open moved from about 20–25 s to about 5–8 s.The rest of the startup wait is not addressed here. After that first video open, each run waited about 45 s before the next video started, before and after this change, while the title polled one runtime provider about 100 times per second.
Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:19:15Z.
Review: COMMENTED
Peer review of PR #1650 (
35ea852e9f7a9065cc599018a6f203504b323768).Findings
tools/startup/debug_launch.pysetsenv.setdefault("_NO_DEBUG_HEAP", "1")before building theCreateProcessWUnicode environment block, andtests/startup_debug_check.pystrips_NO_DEBUG_HEAP(case-insensitively) from the inherited test environment before verifying both the default (debug-probe heap flags 0x0) and_NO_DEBUG_HEAP=0(debug-probe heap flags 0x70).docs/startup-runtime.md,tests/startup_debug_check.py,tests/startup_debug_probe.cpp,tools/startup/debug_launch.py).Verification
python3 -m py_compile /tmp/rev-x2w-75/1650/tools/startup/debug_launch.py /tmp/rev-x2w-75/1650/tests/startup_debug_check.py-> passed.--preset dev):python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 1650 --wait 120-> 3/3 passed (startup_host_cpu_debug0.33s,startup_run_ps12.98s,startup_debug22.10s)./O2(--preset release):x2w_pipe.py win2025run -> 3/3 passed (startup_host_cpu_debug0.34s,startup_run_ps12.90s,startup_debug22.08s).env.setdefault("_NO_DEBUG_HEAP", "1")intools/startup/debug_launch.pyand verified the default launch environment no longer sets_NO_DEBUG_HEAP(the Windows probe intests/startup_debug_check.pyassertsdebug-probe heap flags 0x0\nby default and0x70when_NO_DEBUG_HEAP=0). Reverted cleanly withgit checkout -- ..AI-assisted; commands listed were executed locally.