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
Compiler self-compile peaks at 1.46-1.54 GB; the 1 GiB regression budget went unenforced since #702 #2407
The build graph gives every compiler self-compile (stage1, stage2, ...) a 1 GiB RSS budget (#679/#1665, target_with_compiler_source_inputs in build.w). Since #702 a serial self-compile runs in a worker child while the driver measured its own RSS high-water delta around it (about 0), so the budget never fired. Run as a pooled lane (the readiness scheduler, measured per child through wait4's rusage), stage1 compiled by this tree's release compiler peaks at 1535426560 bytes:
The scheduler change raises the budget to 2 GiB so the check is enforced at all, and this issue tracks where the self-compile's memory grew past 1 GiB (--debug-alloc peak and the largest tables in Sema/MIR).
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced, and the next step is Eric's call. The budget is enforced again, but at twice the old bar: build.w:958-961 reads "2 GiB (2026-10-14): the 1 GiB budget went unenforced from #702 on … measured per lane it is 1.46-1.54 GB. #2407." and sets rss-limit-bytes=2147483648. For scale, with check src/main.w peaks at 788 MB today (/usr/bin/time -l, 64 s).
The question: is 2 GiB the new regression budget, or is it a temporary bar while the self-compile is brought back under 1 GiB? CLAUDE.md's anti-pattern list forbids weakening a check without a human confirming it.
The measuring tool landed: the debug allocator's exit report now states the peak live memory and its shape (bytes, blocks, by origin, a size histogram, the largest requests), and the compiler's own exit prints it (WITH_DEBUG_ALLOC=1 with check …). The compiler checking src/main.w peaks at 750 MB of live payload in 2.4 M blocks: List buffers 393 MB, HashMap tables 280 MB, strings 64 MB, explicit allocations 13 MB; 1.4 M of the live blocks are 64 bytes or smaller; the largest single buffer is a 41 MB List. Max RSS for the same check is 773 MB, so payload is the footprint. The stage compile's own report (the 1.5 GB case) is the next run, under the build's lane; the two numbers to chase are the small-block count (2.4 M blocks is a per-node side-table shape) and the few tens of multi-megabyte Lists.
Correction to how I described this to Eric: the budget is enforced (2 GiB, since the scheduler change), so nothing needs deciding. What this issue tracks is the reduction. Today's seed-driven build reports peak rss 1655M (stage1); the debug allocator's report (750 MB live in 2.4 M blocks for a check of src/main.w: List buffers 393 MB, HashMap tables 280 MB, 1.4 M blocks of 64 bytes or less) names the two shapes to chase. Mine; no label.
Measured 2026-11-23 on main (22166f3) and one branch, macOS arm64. The self-compile behind the 2 GiB tripwire (link-compiler: stage2 building stage3) now sits 8% under its limit, and its peak depends on what else the machine is doing:
run
peak RSS
wall
main, :link-compiler alone
1,880 MB
80.0 s
branch (+40 lines), alone, twice
1,886 MB
79.3 s
same branch inside :release-checks, with a Linux container building beside it
2,064 MB
96.8 s
The third tripped the wire (rss tripwire: target 'link-compiler' peaked at 2163982336 bytes (limit 2147483648 bytes)) and skipped the fixpoint, with no change in the source that could account for 180 MB. Same binary, same input: the peak moves with load, most likely because the parallel back end's work queues hold more live at once when its threads are scheduled late.
the budget has almost no headroom left: 1.46 to 1.54 GB when it was set (2026-10-14), 1.88 GB now.
The limit is not raised. What this issue needs is the self-compile's peak brought down, and the peak made independent of scheduling (a bound on what the back end holds in flight).
Where the peak is, as far as today's tools say (WITH_DEBUG_ALLOC=1 with check src/main.with, main 1bf0982; front end only, no back end):
peak live bytes=932263520 blocks=2638592
peak by origin: List=409385600 HashMap=441866256 str=68062512 with_alloc=12718736
peak by size (bytes>=: blocks): 16:469943 32:1047849 64:480517 128:432403 256:97627 512:58870 1024:29741 …
largest requests: 41287680 List, 20643840 List, 10321920 List, 8388608 List
So checking alone holds 0.93 GB live at its peak, half of the 1.88 GB the self-compile reaches; the back end accounts for the rest. Inside that 0.93 GB: maps 442 MB and lists 409 MB, in 2.6 million live blocks, 1.5 million of them 16 or 32 bytes. That is the shape of very many small per-node or per-symbol collections, not a few large tables (the four largest requests together are 80 MB).
The debug allocator's origins stop at List / HashMap / str. Naming which tables hold the 850 MB needs allocation sites, which is #618 (the call-site profiler); that is the next tool to build for this issue.
The call-site report (#618, built today, not yet merged) names the holders at the self-check's peak (WITH_DEBUG_ALLOC=1 WITH_DEBUG_ALLOC_SITES_AT=258154690 with check src/main.with: 933 MB live in 2.64 M blocks from 9,210 sites). The largest:
278 MB, 30% of the peak, is one table held about 500 times: decl_index_by_node (AST declaration node → declaration index), which sema_empty_state rebuilds over the whole program's declarations for every module's Sema. It is a function of the AST alone, so one copy serves all of them. The two sema_clone_str_list sites are the same pattern (new_module_sema deep-clones decl_source_paths, source_text_names, source_texts per module), from before lists and strings shared their buffers (D111, D120).
Fix in progress: build the index once per AST and give each module's Sema the shared value; make the per-module clones plain value copies.
Root cause, found with the new allocation-site report (WITH_DEBUG_ALLOC_SITES_AT=<n>, #618):
comptime_eval_finish (src/ComptimeEval.with) hands the Sema back with *sema_ptr = synced_sema. A store through a raw pointer releases nothing, so the blank Sema that comptime_take_sema had left there was never released: one leaked per compile-time evaluation. Each blank had also built a declaration index over the whole AST in sema_empty_state (about 520 KB for the compiler's own source), which nothing ever reads.
Fix: the blank is taken out before the store, so it is released; and a blank builds no index (only Sema.init does).
Measured, checking src/main.with with the release compiler:
before
after
peak live bytes
933 MB
584 MB
live blocks at the peak
2,644,569
1,397,070
HashMap bytes at the peak
442 MB
93 MB
compiler build, peak RSS of the compiling stage
1,804 MB
1,417 MB
New test behav_2407_comptime_eval_releases_its_blank_sema: 400 evaluations in a program of 3,400 declarations must check within 64 MB (needed more than 128 MB before; peaks at 39 MB now). Battery running; the tripwire limit is not touched.
Reopened by me: #3580 removed 350 MB, but this issue asks where the self-compile grew past 1 GiB, and the compiling stage still peaks at 1,417 MB. Not done until the 1 GiB budget can be put back. Next: the same allocation-site report on a full compile (the check alone now peaks at 584 MB live, so the rest is in MIR, codegen or LLVM).
Where the memory is, measured on a full compile of the compiler (release compiler at debb845, macOS arm64):
1. The leak (fixed, #3580). 350 MB of blank Semas, one per compile-time evaluation.
2. Everything else is code generation, and it is a chosen trade, not growth. Resident memory sampled every two seconds: about 350 MB through the whole front end (52 s), then a climb to 1,550 MB in the last 20 s while the 16 LLVM units optimize. With's own allocator peaks at 605 MB, spread over 53,924 sites with no large holder left (largest: one 42 MB MIR list, the source texts twice at 23 MB each).
units in flight (WITH_CODEGEN_EMIT_WIDTH)
peak RSS
wall
1
1,089 MB
118 s
4
1,520 MB
76 s
16 (default on a host over 8 GiB)
1,650 MB
75 s
codegen_units_emit_width_for (#681) admits every unit at once on a large host and one at a time on a host of 8 GiB or less. The 1 GiB budget predates that pipeline: on a large host it would measure the window the policy picked, not the compiler.
The tripwire.link-compiler now peaks at 1,477 MB against 2,048 MB (was 1,880 alone and 2,064 under load, which is what turned release checks red). The limit is unchanged.
Not done here, and small: the source texts are deep-copied twice per compile (46 MB), and four units in flight cost the same wall time as sixteen for 130 MB less. Neither moves the result past the table above.
Activity
Battery time: one scheduled graph (75 min to 9.2 min with the new dri…
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced, and the next step is Eric's call. The budget is enforced again, but at twice the old bar:build.w:958-961reads "2 GiB (2026-10-14): the 1 GiB budget went unenforced from #702 on … measured per lane it is 1.46-1.54 GB. #2407." and setsrss-limit-bytes=2147483648. For scale,with check src/main.wpeaks at 788 MB today (/usr/bin/time -l, 64 s).The question: is 2 GiB the new regression budget, or is it a temporary bar while the self-compile is brought back under 1 GiB? CLAUDE.md's anti-pattern list forbids weakening a check without a human confirming it.
#2407: the debug allocator reports the peak live memory and its shape (…
ehartford commentedon Nov 7, 2026
The measuring tool landed: the debug allocator's exit report now states the peak live memory and its shape (bytes, blocks, by origin, a size histogram, the largest requests), and the compiler's own exit prints it (
WITH_DEBUG_ALLOC=1 with check …). The compiler checkingsrc/main.wpeaks at 750 MB of live payload in 2.4 M blocks: List buffers 393 MB, HashMap tables 280 MB, strings 64 MB, explicit allocations 13 MB; 1.4 M of the live blocks are 64 bytes or smaller; the largest single buffer is a 41 MB List. Max RSS for the same check is 773 MB, so payload is the footprint. The stage compile's own report (the 1.5 GB case) is the next run, under the build's lane; the two numbers to chase are the small-block count (2.4 M blocks is a per-node side-table shape) and the few tens of multi-megabyte Lists.ehartford commentedon Nov 18, 2026
Correction to how I described this to Eric: the budget is enforced (2 GiB, since the scheduler change), so nothing needs deciding. What this issue tracks is the reduction. Today's seed-driven build reports
peak rss 1655M (stage1); the debug allocator's report (750 MB live in 2.4 M blocks for a check ofsrc/main.w: List buffers 393 MB, HashMap tables 280 MB, 1.4 M blocks of 64 bytes or less) names the two shapes to chase. Mine; no label.ehartford commentedon Nov 24, 2026
Measured 2026-11-23 on main (22166f3) and one branch, macOS arm64. The self-compile behind the 2 GiB tripwire (
link-compiler: stage2 building stage3) now sits 8% under its limit, and its peak depends on what else the machine is doing::link-compileralone:release-checks, with a Linux container building beside itThe third tripped the wire (
rss tripwire: target 'link-compiler' peaked at 2163982336 bytes (limit 2147483648 bytes)) and skipped the fixpoint, with no change in the source that could account for 180 MB. Same binary, same input: the peak moves with load, most likely because the parallel back end's work queues hold more live at once when its threads are scheduled late.Two consequences:
:release-checksfailure after A variadic function that stores its own next argument is where the argument list starts: libcurl's curl_share_setopt (D213, #3124) #3561, though that log was not kept);The limit is not raised. What this issue needs is the self-compile's peak brought down, and the peak made independent of scheduling (a bound on what the back end holds in flight).
ehartford commentedon Nov 24, 2026
Where the peak is, as far as today's tools say (
WITH_DEBUG_ALLOC=1 with check src/main.with, main 1bf0982; front end only, no back end):So checking alone holds 0.93 GB live at its peak, half of the 1.88 GB the self-compile reaches; the back end accounts for the rest. Inside that 0.93 GB: maps 442 MB and lists 409 MB, in 2.6 million live blocks, 1.5 million of them 16 or 32 bytes. That is the shape of very many small per-node or per-symbol collections, not a few large tables (the four largest requests together are 80 MB).
The debug allocator's origins stop at List / HashMap / str. Naming which tables hold the 850 MB needs allocation sites, which is #618 (the call-site profiler); that is the next tool to build for this issue.
ehartford commentedon Nov 24, 2026
The call-site report (#618, built today, not yet merged) names the holders at the self-check's peak (
WITH_DEBUG_ALLOC=1 WITH_DEBUG_ALLOC_SITES_AT=258154690 with check src/main.with: 933 MB live in 2.64 M blocks from 9,210 sites). The largest:Sema.rebuild_decl_index→with_hashmap_insert→hm_rebuild_indexSema.rebuild_decl_index→hm_grow_entriesSema.rebuild_decl_index→hm_grow_entriesSema.rebuild_decl_index→hm_grow_entriesMirModule.add_body(one list)sema_clone_str_list←Zcu.compile_source_frontend_modesema_clone_str_list←Zcu.new_module_sema278 MB, 30% of the peak, is one table held about 500 times:
decl_index_by_node(AST declaration node → declaration index), whichsema_empty_staterebuilds over the whole program's declarations for every module's Sema. It is a function of the AST alone, so one copy serves all of them. The twosema_clone_str_listsites are the same pattern (new_module_semadeep-clonesdecl_source_paths,source_text_names,source_textsper module), from before lists and strings shared their buffers (D111, D120).Fix in progress: build the index once per AST and give each module's Sema the shared value; make the per-module clones plain value copies.
ehartford commentedon Nov 24, 2026
Root cause, found with the new allocation-site report (
WITH_DEBUG_ALLOC_SITES_AT=<n>, #618):comptime_eval_finish(src/ComptimeEval.with) hands the Sema back with*sema_ptr = synced_sema. A store through a raw pointer releases nothing, so the blank Sema thatcomptime_take_semahad left there was never released: one leaked per compile-time evaluation. Each blank had also built a declaration index over the whole AST insema_empty_state(about 520 KB for the compiler's own source), which nothing ever reads.Fix: the blank is taken out before the store, so it is released; and a blank builds no index (only
Sema.initdoes).Measured, checking
src/main.withwith the release compiler:New test
behav_2407_comptime_eval_releases_its_blank_sema: 400 evaluations in a program of 3,400 declarations must check within 64 MB (needed more than 128 MB before; peaks at 39 MB now). Battery running; the tripwire limit is not touched.The debug allocator names the code holding the memory, and the leak i…
ehartford commentedon Nov 24, 2026
Merged in #3580. The tripwire's own step,
link-compiler, now measures 1,477 MB against the 2,048 MB limit (was 1,880–1,886 alone, 2,064 under load).ehartford commentedon Nov 24, 2026
Reopened by me: #3580 removed 350 MB, but this issue asks where the self-compile grew past 1 GiB, and the compiling stage still peaks at 1,417 MB. Not done until the 1 GiB budget can be put back. Next: the same allocation-site report on a full compile (the check alone now peaks at 584 MB live, so the rest is in MIR, codegen or LLVM).
ehartford commentedon Nov 24, 2026
Where the memory is, measured on a full compile of the compiler (release compiler at debb845, macOS arm64):
1. The leak (fixed, #3580). 350 MB of blank Semas, one per compile-time evaluation.
2. Everything else is code generation, and it is a chosen trade, not growth. Resident memory sampled every two seconds: about 350 MB through the whole front end (52 s), then a climb to 1,550 MB in the last 20 s while the 16 LLVM units optimize. With's own allocator peaks at 605 MB, spread over 53,924 sites with no large holder left (largest: one 42 MB MIR list, the source texts twice at 23 MB each).
WITH_CODEGEN_EMIT_WIDTH)codegen_units_emit_width_for(#681) admits every unit at once on a large host and one at a time on a host of 8 GiB or less. The 1 GiB budget predates that pipeline: on a large host it would measure the window the policy picked, not the compiler.The tripwire.
link-compilernow peaks at 1,477 MB against 2,048 MB (was 1,880 alone and 2,064 under load, which is what turned release checks red). The limit is unchanged.Not done here, and small: the source texts are deep-copied twice per compile (46 MB), and four units in flight cost the same wall time as sixteen for 130 MB less. Neither moves the result past the table above.