Skip to content

Floor latency: whole-closure Rust emit asks the cheap half of each question first - #12454

Merged
briansrls merged 1 commit into
mainfrom
floor-latency/emit-renders-once
Sep 28, 2026
Merged

briansrls merged 1 commit into
mainfrom
floor-latency/emit-renders-once

Conversation

@briansrls

Copy link
Copy Markdown
Contributor

Part of the floor-latency program (target: required floor under 30 min). This PR shortens the stage0 build lane, which after the job split runs as the merge queue's generated job: two whole-closure emits per queued landing, 4m45s and 5m20s on merge-queue run 36339106604.

What. Three places in the seed Rust emitter (src/v1/05_emit_rust.dag) did corpus-sized work whose answer a cheaper half already decided:

  • closure_needs_module_filename_stub walked every module's reference candidates before checking whether the module is in the closure at all. In a whole-closure emit it always is, so both stub decisions walked the closure only to throw the result away. Absence is now checked first.
  • build_emit_rust_context merged all modules' source indices four times over the same input. It now merges once.
  • struct_candidates_by_field_names built and sorted each struct's key list once per struct per anonymous record literal. Presence is now checked first, and the count no longer sorts. The parser refuses repeated field inits, so presence plus equal count is still set equality.

Output unchanged. A seed built from this mirror regenerates all 161 stage0 mirrors equal to the committed ones (first_generation_equal=true).

Measured on one host, same load window: whole-closure compile.emit 5 min → 4 min. A baseline perf profile of that emit puts struct_candidates_by_field_names at 36% inclusive. The remaining cost is one pass over every type summary per literal; an index keyed by field set is the follow-up.

Overlap with #12448. That PR removes the emitter's 2^depth double renders in the same .dag file and the same generated mirror, so whichever lands second regenerates v1_compiler_emit_rust.rs. Both leave emitted text unchanged, so the regeneration is mechanical.

🤖 Generated with Claude Code

Three places in the seed Rust emitter did corpus-sized work whose answer the
cheaper half already decided, or repeated one fold four times.

- closure_needs_module_filename_stub asked "does anything reference this
  module" (a walk of every module's reference candidates) before "is the
  module already in the closure" (one name per module). In every
  whole-closure emit -- the stage0 regen -- the module IS in the closure, so
  both stub decisions walked the whole closure to produce a Bool the
  conjunction then discarded. Absence is now asked first, reading each
  module's own source index rather than a merge of all of them.
- build_emit_rust_context merged every module's source indices four times
  over the same input; it now merges once.
- struct_candidates_by_field_names built and SORTED each struct's whole key
  list before comparing a single name, once per struct per anonymous record
  literal; presence is now asked first (a hash lookup that short-circuits on
  the first missing field) and the count reads the keys unsorted. The
  literal's names are unique (02_parse refuses a repeated field init), so
  presence plus equal count is set equality, as before.

Emitted text is unchanged: the seed built from this mirror regenerates all
161 stage0 mirrors equal to the committed ones (first_generation_equal=true),
and its whole-closure compile.emit took 4 min against 5 min for the seed
before it on the same host. The struct-candidate scan is still one pass over
every type summary per literal; an index keyed by field set is the next step.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T21:57:57.717207Z 3a68301 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@briansrls
briansrls added this pull request to the merge queue Sep 27, 2026
Merged via the queue into main with commit 5df4bef Sep 28, 2026
5 checks passed
@briansrls
briansrls deleted the floor-latency/emit-renders-once branch September 28, 2026 03:11
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