Repository navigation
A constant map declared as a fn was rebuilt on every builtin lookup: compile.reconcile 49s to 43s on the seed closure, byte-identical output - #9668
Conversation
…compile.reconcile 49s to 43s on the seed closure, byte-identical output
`builtin_function_registry` held 132 fixed rows and was written as a `fn` whose body
reconstructed the whole map through 131 sequential `map_insert`s. `infer_builtin_call_type`
calls it once per lookup, so every "is this name a builtin" question paid a full
reconstruction — and in the emitted mirror each insert received a shared `Rc` handle, so
`Rc::make_mut` deep-copied the map 131 times per call, quadratic in the registry's own size.
Measured on the seed closure (`--entry src/v1/compile.dag`, 108 files) by nested `Instant`
marks compiled into the mirror — throwaway, reverted; the committed mirror is regen output:
compile.reconcile 49s
typecheck_module x102 29.4s
infer_items 24.1s
infer_builtin_call_type 3.9s 12,351 calls, 316us each
Declaring it as `data` lowers the identical rows through the cached-constant path already
used by `std.types` `kernel_type_set`: one `thread_local` map built with direct inserts, once
per thread, read by key. Same keys, same value expressions; the `set_ty` local is inlined at
its three uses because a `data` initializer carries no let bindings. `seed_node_map` had no
other caller and is deleted rather than left as a forwarder.
Receipts, both from one remote dispatch that builds both binaries and alternates them:
compile.reconcile 50s/48s before, 43s/43s after; the two emitted trees are byte-identical and
both report 2180 diagnostics. `claim_executor --required-regen` reports
`first_generation_equal=true`, so the seed reproduces itself from the new declaration.
This is `BehaviorPreservingRedundancyRemoval` under the v1 freeze
(`gunbc.v1_maintenance_standing`) — a proven cost-shape defect, DESIGN section 6 bare-minimum
cost, the same class as #9666. `05_emit_rust` asks the same question through the same
function, so the emit lane is served by the same row.
NOT addressed here, and the larger remaining item: `authored_name_at` is called 29,731,495
times in one reconcile (~10s), re-slicing a fresh `String` out of the raw char codes for every
"what is this node called" question, on identifiers the frontend has already interned. That is
a modeling change to the name carrier rather than a cost-shape fix, and it wants its own
measurement.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBRjpfaGRgW1agXecf3bpH
|
CI red here is pre-existing main breakage, not this change. Receipt:
Same seven identities in every column, and this change's emitted tree is byte-identical to its base ( Two root causes found while checking, offered for whoever picks up the main unbreak — neither is reachable from this PR:
Note the seven were not introduced by #9662 — it unmasked them. Before it, every floor run aborted at — sent from bold-wolf-399 |
Auto-opened by session-dashboard for session
bold-wolf-399.Pushing to
session/bold-wolf-399advances this PR.Worker attestation
Before flipping this PR to ready for review, confirm each item:
npm test,cargo test) and the result.Closes #Ndirective.Summary
TODO: replace this paragraph with one or two sentences naming the change and its motivation. Reviewers read this first.
Test plan