You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows: the seed compiling stage1 commits 8.1 GiB (1.7 GiB resident for the same compile on macOS) #3364
Seen on the win10 VM (16 GiB) on 2026-11-16 while measuring #3031: during src/main.exe build :test at 0c2a0c9, the largest committed process before the test phase was main.exe (the pinned seed) compiling stage1: 8114 MBPagedMemorySize64. The same compile peaks near 1.7 GiB resident on macOS ([times] … stage1 … peak rss 1662M). A release compiler building a compiler-importing test on the same VM commits about 1.3 GiB, so this is specific to the whole-compiler compile (or to that seed).
Windows charges committed memory whether or not it is touched, and the runtime's rt_mmap there is VirtualAlloc(MEM_COMMIT | MEM_RESERVE) for every mapping. Candidates: a large region mapped once and touched sparsely (reserve without commit would cost nothing), or per-unit arenas of the 16 codegen units.
On a 16 GiB hosted runner this one compile takes half the machine. It is not what failed the nightly (#3031 was 27 test compilers at once), but it is the next thing that will.
To do. Sample again with the current release compiler compiling out/gen/main.w on the VM (recipe in handoff.md: a With sampler that runs PowerShell Get-Process every 3 s), then find the mapping with the debug allocator's peak-by-origin lines, and reserve-then-commit where a region is sparse.
rt_munmap: VirtualFree(ptr, 0, MEM_RELEASE), and every caller passes the mapping's base, so releases are not silently failing.
The allocator's own tables (rt_owned_record_slab, rt_range_table_grow) double and release the old table.
So nothing in rt/ maps a large region and touches it sparsely. What is left is what cannot be read from here: the UCRT heap that LLVM allocates from (16 codegen units), and whether the figure is the pinned seed's alone (it predates #3103's cache and several allocator changes). The measurement in the issue's to-do decides: the same compile with the current release compiler, and the debug allocator's peak-by-origin lines against the commit figure (a gap between the two is LLVM's heap, not the runtime).
This needs the Windows VM. It is not urgent, so it is batched with the next session that starts the VM anyway (the Windows seed leg, once #3374 and #3375 are ruled).
Needs Eric: this is investigated in a Windows session on the VM, which he keeps off except for Windows-specific work, and it sits behind the seed cut whose darwin leg he stopped on 2026-11-18. Asked for a go on both; nothing here moves until then.
Ruled, 2026-11-18: go. Measure with the current seed first (the old one is replaced). Hypothesis to test: Windows charges memory at commit and macOS at touch, so anything that commits a large region up front shows as 8 GiB on one and 1.7 GiB on the other, in our allocator or in LLVM's.
Measured 2026-11-18 on the win10 VM with the current pinned seed (nightly-20261118-…-26eb17e89e67), a Win32_Process sampler every 3 s, the process identified by its command line.
Compile of out/gen/main.w -O1
Committed
Resident
As build :dev's child (the driver sets WITH_CODEGEN_UNITS=16, width 4)
Established. It is resident, not commit-only. It is not the old seed, not type checking, not emit parallelism. The 16-unit layout doubles the figure on Windows and costs nothing on macOS. With the allocator capped at 3 GB the 16-unit compile succeeds at 3.97 GB, so the extra 4 GB is in our allocator and is not needed: without a cap that binds, the allocator keeps mapping. (rt_set_process_memory_limit_bytes is a no-op on Windows, so the cap is only the allocator's own.)
Not yet found. The line. The large-block cache is capped at 96 MiB, so flushing it does not explain 4 GB; next is what else the limit path triggers, the empty-slab sweep schedule, and the freelists under four emit threads. A second gap remains at the default layout (4.06 GB against 1.76 GB).
Also.build/compiler.w's comment on the 16-unit layout gives darwin figures (3.1 to 7.2 GB) that are no longer true there. The build's own peak-memory figure for this compile is wrong on Windows: #3456.
Correction to the comment above (same day). "The extra 4 GB is in our allocator" is not established. Exceeding the allocator's limit is fatal (rt_alloc_report_limit_exceeded exits 125) and the only memory the limit path releases is the large-block cache, capped at 96 MiB, so a cap cannot have saved 4 GB. Two variables changed between the 8.4 GB runs and the 4 GB runs: every 8.4 GB run was the build driver's child, and every ~4 GB run was launched directly. The 16-unit layout was never run directly without a cap, so "16 units doubles it" is not established either.
What the table does establish: as build :dev's child the compile holds 8.4 GB resident; launched directly (default layout, or 16 units with a cap) about 4 GB; check 1.2 GB; macOS 1.6 to 1.8 GB.
So the driver gives that compile something beyond the unit count that costs about 4 GB on Windows. It also sets WITH_RUNTIME_ROOT, WITH_COMPILER_EMBEDDED_OBJECT, WITH_OUT_DIR, WITH_FILE_PREFIX_MAP and the link inputs for that step (build/compiler.w around line 706). Next: read what the compile does with those on Windows (embedding and the link are the candidates: file contents read into memory where macOS maps them), then one planned VM batch that changes one variable per run.
Waiting on Eric's go for one planned Windows VM batch (2026-11-19): his other work runs on that host, so the VM starts only when he agrees, with the runs listed first. The batch: the 16-unit layout launched directly with no cap; the direct compile with each of the build driver's extra variables in turn; and, for #3456, the pid and command line the driver reaps for stage1.
Root cause (planned VM batch, 2026-11-19). One sampler over the whole batch, each process identified by id, parent and command line; committed MB:
Run (direct compile of out/gen/main.w -O1, 16 units, width 4)
Committed
no other variable
3,912
+ WITH_FILE_PREFIX_MAP
8,489
+ WITH_OUT_DIR
3,988
+ WITH_RUNTIME_ROOT
3,953
all three
8,497
build :dev (the driver's child)
8,563
So the doubling is one variable being set, not the unit count (my earlier correction stands: neither the cap nor the units decided it).
The line.rt/windows_x86_64.w, rt_getenv: let buf = rt_mmap(len + 1). Every successful read of a variable maps a fresh region for the value (at least one committed page, written) and never frees it; the comment calls it a process-lifetime region, so that two results never alias. src/FnAbi.w reads WITH_FILE_PREFIX_MAP on every source-path canonicalisation (fn_abi_file_prefix_mapped, fn_abi_file_prefix_map_names), about a million times in this compile: 4.5 GB. Linux and macOS return a pointer into environ and allocate nothing. Every other variable that is set and read often leaks the same way, which is the rest of the gap to macOS (4 GB against 1.7 GB).
Fix (in progress).rt_getenv on Windows keeps one buffer per variable and value, compared in UTF-16 so a repeat read maps and converts nothing; a changed value gets a new buffer and the old one stays mapped for whoever holds it. Same in rt/windows_aarch64.w. src/ is linked with the pinned seed's runtime, so the compiler itself gets it at the next seed pin.
The fix is merged (#3466). The Windows x86_64 lane on the branch passed every test target with it. Not yet measured: the compiler's own memory falls only once a seed carrying this runtime is pinned (src/ is linked with the pinned seed's runtime). This issue closes when that compiler is measured on Windows.
Setting the variable no longer costs anything, which is the fix in #3466 (one buffer per variable and value in rt_getenv). The seed's remaining 500 MB over the tree's compiler is the compile-time-evaluation leak fixed today in #3580, which that seed predates.
macOS, same compile: 1,650 MB resident. So Windows is no longer the outlier.
The figures come from the job object the runtime already gives each child (the #3456 fix, in review); the same launcher's figure for a direct child matched an external sampler within 3% on 2026-11-18.
Activity
ehartford commentedon Nov 16, 2026
Ruled out by reading the runtime (main 9edaa62), before the next VM session:
allocate_stack_regionmaps 64 KiB + 64 KiB headroom + a guard page per fiber (FIBER_STACK_SIZE = 65536); not gigabytes.CreateThread(…, 0, …)takes the image's default; no/STACKis passed at link, so each thread reserves 1 MiB and commits a page.RT_LARGE_CACHE_BYTES= 96 MiB, blocks up to 2 MiB.rt_munmap:VirtualFree(ptr, 0, MEM_RELEASE), and every caller passes the mapping's base, so releases are not silently failing.rt_owned_record_slab,rt_range_table_grow) double and release the old table.So nothing in
rt/maps a large region and touches it sparsely. What is left is what cannot be read from here: the UCRT heap that LLVM allocates from (16 codegen units), and whether the figure is the pinned seed's alone (it predates #3103's cache and several allocator changes). The measurement in the issue's to-do decides: the same compile with the current release compiler, and the debug allocator's peak-by-origin lines against the commit figure (a gap between the two is LLVM's heap, not the runtime).This needs the Windows VM. It is not urgent, so it is batched with the next session that starts the VM anyway (the Windows seed leg, once #3374 and #3375 are ruled).
ehartford commentedon Nov 18, 2026
Needs Eric: this is investigated in a Windows session on the VM, which he keeps off except for Windows-specific work, and it sits behind the seed cut whose darwin leg he stopped on 2026-11-18. Asked for a go on both; nothing here moves until then.
ehartford commentedon Nov 19, 2026
Ruled, 2026-11-18: go. Measure with the current seed first (the old one is replaced). Hypothesis to test: Windows charges memory at commit and macOS at touch, so anything that commits a large region up front shows as 8 GiB on one and 1.7 GiB on the other, in our allocator or in LLVM's.
ehartford commentedon Nov 19, 2026
Measured 2026-11-18 on the win10 VM with the current pinned seed (
nightly-20261118-…-26eb17e89e67), a Win32_Process sampler every 3 s, the process identified by its command line.out/gen/main.w -O1build :dev's child (the driver setsWITH_CODEGEN_UNITS=16, width 4)WITH_CODEGEN_EMIT_WIDTH=1WITH_MEMORY_LIMIT_BYTES=3000000000checkonlyEstablished. It is resident, not commit-only. It is not the old seed, not type checking, not emit parallelism. The 16-unit layout doubles the figure on Windows and costs nothing on macOS. With the allocator capped at 3 GB the 16-unit compile succeeds at 3.97 GB, so the extra 4 GB is in our allocator and is not needed: without a cap that binds, the allocator keeps mapping. (
rt_set_process_memory_limit_bytesis a no-op on Windows, so the cap is only the allocator's own.)Not yet found. The line. The large-block cache is capped at 96 MiB, so flushing it does not explain 4 GB; next is what else the limit path triggers, the empty-slab sweep schedule, and the freelists under four emit threads. A second gap remains at the default layout (4.06 GB against 1.76 GB).
Also.
build/compiler.w's comment on the 16-unit layout gives darwin figures (3.1 to 7.2 GB) that are no longer true there. The build's own peak-memory figure for this compile is wrong on Windows: #3456.ehartford commentedon Nov 19, 2026
Correction to the comment above (same day). "The extra 4 GB is in our allocator" is not established. Exceeding the allocator's limit is fatal (
rt_alloc_report_limit_exceededexits 125) and the only memory the limit path releases is the large-block cache, capped at 96 MiB, so a cap cannot have saved 4 GB. Two variables changed between the 8.4 GB runs and the 4 GB runs: every 8.4 GB run was the build driver's child, and every ~4 GB run was launched directly. The 16-unit layout was never run directly without a cap, so "16 units doubles it" is not established either.What the table does establish: as
build :dev's child the compile holds 8.4 GB resident; launched directly (default layout, or 16 units with a cap) about 4 GB;check1.2 GB; macOS 1.6 to 1.8 GB.So the driver gives that compile something beyond the unit count that costs about 4 GB on Windows. It also sets
WITH_RUNTIME_ROOT,WITH_COMPILER_EMBEDDED_OBJECT,WITH_OUT_DIR,WITH_FILE_PREFIX_MAPand the link inputs for that step (build/compiler.waround line 706). Next: read what the compile does with those on Windows (embedding and the link are the candidates: file contents read into memory where macOS maps them), then one planned VM batch that changes one variable per run.ehartford commentedon Nov 19, 2026
Waiting on Eric's go for one planned Windows VM batch (2026-11-19): his other work runs on that host, so the VM starts only when he agrees, with the runs listed first. The batch: the 16-unit layout launched directly with no cap; the direct compile with each of the build driver's extra variables in turn; and, for #3456, the pid and command line the driver reaps for
stage1.ehartford commentedon Nov 19, 2026
Root cause (planned VM batch, 2026-11-19). One sampler over the whole batch, each process identified by id, parent and command line; committed MB:
out/gen/main.w -O1, 16 units, width 4)WITH_FILE_PREFIX_MAPWITH_OUT_DIRWITH_RUNTIME_ROOTbuild :dev(the driver's child)So the doubling is one variable being set, not the unit count (my earlier correction stands: neither the cap nor the units decided it).
The line.
rt/windows_x86_64.w,rt_getenv:let buf = rt_mmap(len + 1). Every successful read of a variable maps a fresh region for the value (at least one committed page, written) and never frees it; the comment calls it a process-lifetime region, so that two results never alias.src/FnAbi.wreadsWITH_FILE_PREFIX_MAPon every source-path canonicalisation (fn_abi_file_prefix_mapped,fn_abi_file_prefix_map_names), about a million times in this compile: 4.5 GB. Linux and macOS return a pointer intoenvironand allocate nothing. Every other variable that is set and read often leaks the same way, which is the rest of the gap to macOS (4 GB against 1.7 GB).Fix (in progress).
rt_getenvon Windows keeps one buffer per variable and value, compared in UTF-16 so a repeat read maps and converts nothing; a changed value gets a new buffer and the old one stays mapped for whoever holds it. Same inrt/windows_aarch64.w.src/is linked with the pinned seed's runtime, so the compiler itself gets it at the next seed pin.Windows: getenv keeps one buffer per variable and value; a variable r…
ehartford commentedon Nov 19, 2026
The fix is merged (#3466). The Windows x86_64 lane on the branch passed every test target with it. Not yet measured: the compiler's own memory falls only once a seed carrying this runtime is pinned (
src/is linked with the pinned seed's runtime). This issue closes when that compiler is measured on Windows.ehartford commentedon Nov 24, 2026
Measured on Windows (win10 VM, 16 GiB, one planned batch, 2026-11-23); the VM is off again.
The same compile as in the root-cause table (
out/gen/main.with -O1, 16 units, 4 in flight), peak committed by the compiling process:WITH_FILE_PREFIX_MAPSetting the variable no longer costs anything, which is the fix in #3466 (one buffer per variable and value in
rt_getenv). The seed's remaining 500 MB over the tree's compiler is the compile-time-evaluation leak fixed today in #3580, which that seed predates.macOS, same compile: 1,650 MB resident. So Windows is no longer the outlier.
The figures come from the job object the runtime already gives each child (the #3456 fix, in review); the same launcher's figure for a direct child matched an external sampler within 3% on 2026-11-18.