Skip to content

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

Merged
briansrls merged 2 commits into
mainfrom
session/bold-wolf-399
Aug 29, 2026
Merged

briansrls merged 2 commits into
mainfrom
session/bold-wolf-399

Conversation

@briansrls

Copy link
Copy Markdown
Contributor

Auto-opened by session-dashboard for session bold-wolf-399.
Pushing to session/bold-wolf-399 advances this PR.

Worker attestation

Before flipping this PR to ready for review, confirm each item:

  • Title describes the change (not the session id or branch).
  • PR body summarises what and why (replace the TODO below).
  • Tests run: name the command (e.g. npm test, cargo test) and the result.
  • If this closes a work item, the body contains a Closes #N directive.
  • No commits on this branch are surprises (no fork/cherry-pick I did not make).
  • No secrets / credentials / large binaries staged.

Summary

TODO: replace this paragraph with one or two sentences naming the change and its motivation. Reviewers read this first.

Test plan

  • TODO: list the commands that ran (or "no tests changed; relied on CI") and the outcome.

…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
@gunbai-bot gunbai-bot Bot changed the title v1 reconcile performance 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 Aug 29, 2026
@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review August 29, 2026 08:00
@gunbai-bot

gunbai-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

CI red here is pre-existing main breakage, not this change. Receipt:

revision contains this PR unexpected_failures
main dda42363 (this PR's original base) no 7
main b305e4eb (current main) no 7
this PR 17bcdbe0 yes 7
this PR 5a2cd0dc (after merging current main) yes 7

Same seven identities in every column, and this change's emitted tree is byte-identical to its base (diff -r over both emitted trees, 2180 diagnostics on both sides). main's witnesses workflow has failed on 20 consecutive commits.

Two root causes found while checking, offered for whoever picks up the main unbreak — neither is reachable from this PR:

  1. Moved-file rot from Fix the unparseable rung-drop record, and start the cli_run.rs decomposition (13 clusters to named submodules) #9648's cli_run.rs decomposition. [floor-claim-memory] now lives in src/v1/stage0/src/cli_run/required_floor_runner.rs, but gunbc.observation_emit_census seed_emit_sources still lists only src/v1/stage0/src/cli_run.rs, so the census searches a denominator that no longer covers the emit and the marker reads absent. test.claim.observation_lockstep_witness_test pins the same path in heartbeat_source_path. This is precisely the rot censused_emit_site_has_no_source_file_note predicts for a positional citation — it went false because the emit MOVED. Accounts for the two observation_emit_census_witness_test rows and the observation_lockstep_witness_test row.

  2. A different cause for discovery_census_witness (3 rows) — that suite is fixture-based (mixed_sites()) with no live-tree paths, so the count assertions in w_counts_partition_the_offered_population are failing on their own terms, not on a moved path.

Note the seven were not introduced by #9662 — it unmasked them. Before it, every floor run aborted at unresolved import: module 'examples.js_site' not found and never reached the witness phase, so those runs reported zero FAIL lines because nothing executed, not because anything passed.

— sent from bold-wolf-399

@briansrls
briansrls merged commit 4ecf2c0 into main Aug 29, 2026
1 of 3 checks passed
@briansrls
briansrls deleted the session/bold-wolf-399 branch August 29, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant