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
The D89/D93 re-check rounds re-derive a whole module to hear one decision: 28% of the compiler's map lookups on check src/main.w #3099
From #3093's measurement: of 2.6B map lookups in one check src/main.w, 0.67B are in the tables of Sema instances that Zcu.compile_source_frontend_mode creates for the D89 probe (field numeric types from use) and the D93 literal rounds (collection literal types from use) and drops when the round ends. Each round is a complete check of the module with the previous round's decisions installed.
The question is whether a round has to re-check everything. A decision changes the types of the bindings it names and what flows from them; bodies that mention none of them are unchanged. Options: (a) re-check only the bodies whose decl set intersects the decided bindings (the body-order machinery already knows each body's names); (b) keep the first round's Sema and re-check in place with the decisions applied, instead of a fresh Sema that re-collects every declaration; (c) decide more in the first round (a demand heard early enough is a decision, not a round).
Measure first: WITH_PROFILE=1 already prints per-phase time; add the round count per module and the time per round, then the share of check src/main.w the extra rounds cost.
Measured (branch i3099: the frontend's [profile] frontend.sema line now carries checks=K probe-ms=P literal-rounds=L rounds-ms=R; WITH_PROFILE=1 with-stage1 check src/main.w):
[profile] frontend.sema 107266 ms decls=20884 int-local-rechecks=35 checks=2 probe-ms=0 literal-rounds=1 rounds-ms=53336
The compiler is one module of 20,884 declarations, and Sema runs over it twice: the check, then one D93 literal round, and the round is 53.3 s of 107.3 s: half of all Sema time, re-deriving everything to apply the decisions of a handful of let x = []-style bindings whose collection type their uses decided. No D89 probe (no inferred numeric fields in src/).
Next: list the bindings that force the round (their count and sites), then decide between re-checking only the bodies that mention them and deciding them in the first pass; either removes about 40% of check src/main.w.
The bindings that force the second pass over the compiler (the profile now lists them as [profile] literal-demand): 17, all locals of the form let xs = [] whose element type the first push a few lines later decides:
Seventeen body-local decisions, each visible within its own body, and the price is one more Sema pass over 20,884 declarations: 53 s. Annotating them would buy the time back today, at the cost of the census's list-annotation count and of writing what the compiler knows (two of the 17 are from this week's sweeps dropping exactly such annotations). The fix in the compiler is to re-check only the body that holds the decided binding: int-local-rechecks=35 on the same line says a per-body re-check already exists for D126's int locals, so the literal decision takes the same route and the module-wide round goes.
Fixed on branch i3099: a body's settle loop (the one D126's int locals already use) takes the literal demands its pass recorded, makes them body decisions, drops the pass's diagnostics and checks the body again at the decided types; a binding two typed uses disagree about still goes to the module round for its error. Measured on check src/main.w:
before: checks=2 frontend.sema 107266 ms (literal round 53336 ms)
after: checks=1 frontend.sema 53930 ms
The 134 literal-typing fixtures pass (including err_d93_two_demands, which the first version lost by deciding the second demand alone), plus a new fixture for three in-body shapes. Gate running; battery next.
Activity
ehartford commentedon Nov 8, 2026
Measured (branch
i3099: the frontend's[profile] frontend.semaline now carrieschecks=K probe-ms=P literal-rounds=L rounds-ms=R;WITH_PROFILE=1 with-stage1 check src/main.w):The compiler is one module of 20,884 declarations, and Sema runs over it twice: the check, then one D93 literal round, and the round is 53.3 s of 107.3 s: half of all Sema time, re-deriving everything to apply the decisions of a handful of
let x = []-style bindings whose collection type their uses decided. No D89 probe (no inferred numeric fields insrc/).Next: list the bindings that force the round (their count and sites), then decide between re-checking only the bodies that mention them and deciding them in the first pass; either removes about 40% of
check src/main.w.ehartford commentedon Nov 8, 2026
The bindings that force the second pass over the compiler (the profile now lists them as
[profile] literal-demand): 17, all locals of the formlet xs = []whose element type the firstpusha few lines later decides:Seventeen body-local decisions, each visible within its own body, and the price is one more Sema pass over 20,884 declarations: 53 s. Annotating them would buy the time back today, at the cost of the census's
list-annotationcount and of writing what the compiler knows (two of the 17 are from this week's sweeps dropping exactly such annotations). The fix in the compiler is to re-check only the body that holds the decided binding:int-local-rechecks=35on the same line says a per-body re-check already exists for D126's int locals, so the literal decision takes the same route and the module-wide round goes.ehartford commentedon Nov 8, 2026
Fixed on branch
i3099: a body's settle loop (the one D126's int locals already use) takes the literal demands its pass recorded, makes them body decisions, drops the pass's diagnostics and checks the body again at the decided types; a binding two typed uses disagree about still goes to the module round for its error. Measured oncheck src/main.w:The 134 literal-typing fixtures pass (including
err_d93_two_demands, which the first version lost by deciding the second demand alone), plus a new fixture for three in-body shapes. Gate running; battery next.#3099: a literal binding its uses type is decided in its own body, no…
#3099: a literal binding its uses type is decided in its own body, no…
#3099: a literal binding its uses type is decided in its own body, no…