Skip to content

comp.ts simplifications: ty_holds, CID_T, tele_fill, corpus_at and more - #1457

Merged
Lorenzobattistela merged 7 commits into
mainfrom
simplify-comp-3
Oct 10, 2026
Merged

Lorenzobattistela merged 7 commits into
mainfrom
simplify-comp-3

Conversation

@nicolas-abril

@nicolas-abril nicolas-abril commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Behaviour-preserving simplifications of bend2/comp.ts. They free 183 ttok (63,905 → 63,722). Each commit covers one area:

  • ty_holds, lay_el, task_deliver, gpu_load, startup:
    • ty_holds now looks inside every datatype except the words itself, so its predicate just returns true/false for what it is looking for. ty_value, ty_clo, lay_of's recursion check and js_marshal's Nat test no longer spell out the walk.
    • lay_el writes its type formers inline.
    • task_deliver computes its count cell once.
    • Metal gpu_load has one failure path.
    • corpus_setup and C main drop their one-use temporaries.
  • term_const, lay_el, mat_ctrs:
    • Removes term_const's dead length === 0 guard ([].every is already true).
    • lay_el returns BOX directly for type formers, where lay_of always gave BOX on that branch.
    • Fixes a line break in mat_ctrs so its nested ternary reads the way it parses.
  • node_fields, emit_open, show_main:
    • node_fields builds its scratch reads without patching strings.
    • emit_open names a parameter's words and marks the borrowed ones in one pass.
    • show_main's node checks its cache before computing anything.
  • compile_book:
    • The shown constructor names are worked out once, for both the roots and SHOW_NAMES.
    • cid() stores each encoded arity where the constructor is met, so the ars array zipped by index with cids is gone.
    • js_def uses def_foreign.
  • tele_fill: a wrapper next to tele_unbind for the four Bend.tele_fill(FL.book, T, xs, Bend.ctx_nil()) calls.
  • corpus_at: one host-only helper for "map exactly at this address, give the mapping back otherwise", which corpus_map and corpus_grow both repeated.

Hot runtime paths and device code were deliberately left alone. During the drop work on #1438, an "obvious" merge of ctr_take's two loops cost about 6% on lexer's Metal run.

Validation

  • Generated code: every #| test and all 17 runtime benches give byte-identical JS and compiler logs to main. Every .c file differs only in the task_deliver, gpu_load, corpus_setup, main and corpus_at lines. That was checked per commit, and again for the combined branch, where all 762 C diffs are identical.
  • Gates on the cluster: repo 54/54, test 1597/1597, ping 47/47, perf 124/124.
  • Perf flake: in 2 of 9 combined _run.ts runs on the first commit, perf came back 123/124. The full perf tables put the closest cells at merkle COMPILER and generics_3200 CHECKER, which are near the 1.15× limit on main too. Alternating rounds against main passed 124/124 every time.
  • corpus_grow: exercised with an 8 GiB array, so the arena doubled twice through the new helper. Metal builds and --gpu on/off outputs match main.
  • tsc: no errors in comp.ts.

#1438 carries the first commit too. Once this lands, it rebases onto it.

🤖 Generated with Claude Code

nicolas-abril and others added 6 commits October 9, 2026 19:52
ty_holds looks into every datatype but the words itself, so its tests
say only what they seek, true or false: ty_value, ty_clo, lay_of's
recursion and js_marshal's Nat no longer spell the walk out. lay_el
names its formers inline, task_deliver names its count cell once,
gpu_load fails once with the message that fits, and corpus_setup and
main drop their one-use temporaries. Every test emits the same JS, and
the same C but for those lines.

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

[].every is true, so term_const's empty-argument case was the general
one. lay_el's non-datatype branch returned lay_of(A), which is BOX for
anything that is not a datatype; it returns BOX, and the Lay comment
says a former is a box whatever its parts mention. mat_ctrs breaks its
nested ternary where it nests. Every test and bench emits the same C
and JS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
node_fields picks its scratch reads and its sp source in one expression
each, no longer patching strings; emit_open names a parameter's words
and marks the borrowed ones in one pass; show_main's node looks up its
cache before computing what a miss needs. Every test and bench emits
the same C and JS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The show descriptor's constructor names are filtered once for the
roots and SHOW_NAMES; cid() stores a constructor's encoded arity where
it is met, so the ars array zipped with cids goes; js_def asks
def_foreign. Every test and bench emits the same C and JS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
corpus_map's hint loop and corpus_grow's doubling both tried a mapping
at a fixed address and unmapped one that landed elsewhere; corpus_at
does it for both. Host-only: once at startup, and on each doubling.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Four callers spelled out Bend.tele_fill(FL.book, T, xs, Bend.ctx_nil());
the Tele section names it beside tele_unbind. Every test and bench
emits the same C and JS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@nicolas-abril nicolas-abril changed the title comp.ts simplifies ty_holds, lay_el, task_deliver, gpu_load and startup comp.ts simplifications: ty_holds, CID_T, tele_fill, corpus_at and more Oct 9, 2026
A predicate answers whether a type is the one sought; ty_holds looks
into each datatype it rejects, but for the words. ty_value and ty_clo
reject "ADT" for that reason.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Lorenzobattistela
Lorenzobattistela merged commit 0a76cb8 into main Oct 10, 2026
1 check passed
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.

2 participants