Skip to content

comp.ts sheds 586 tokens: tighter runtime and comments, a pure main prints through Bend code (from #1817) - #1829

Closed
Lorenzobattistela wants to merge 5 commits into
mainfrom
comp-shed-printer
Closed

Lorenzobattistela wants to merge 5 commits into
mainfrom
comp-shed-printer

Conversation

@Lorenzobattistela

Copy link
Copy Markdown
Collaborator

comp.ts goes from 66,000 to 65,414 ttok (−586), leaving room under the 66k cap.

Trims (−120)

  • term_peek, rfc_seal, term_keep and blk_read in the C runtime are one-line ternaries.
  • ty_key(t) replaces five copies of Bend.term_key(Bend.term_lower(t)).
  • A few comments are tighter, and three sentences that restated the code next to them are gone.

A pure main prints through Bend code (−466, from #1817)

Verification

  • repo 54/54, test 1711/1711 (1707 + the 4 new tests), ping 73/73, all inside the 30 s cap.
  • safe: identical to main's (1,114 agree, 0 false rejects).
  • Before the port, JS and .mjs output were byte-identical to main's on all 1,308 programs that check, and C differed only by the four runtime ternaries. After the port, every runtime bench's C differs from main's only in the removed printer code, which MAIN_PURE (0 for them) already compiled out.
  • cc -O3 host assembly is identical to main's for all 17 runtime benches, before and after the port. Metal device IR was identical too before the port.
  • All test builds take 7.1 s in total, against main's 5.9 s.
  • perf: 120–123 of 124 on this branch, and main also misses (122–123 of 124 in the same hour). The histogram SEQ-CPU cell reads ~1.25x on main and on this branch: built on its mini (cluster-0e), main's binary and this branch's have the same SHA and run 1.85–1.87 s there. The other misses (bfs, merkle, editdist, tree-bitonic) move between runs and also hit main.

🤖 Generated with Claude Code

Lorenzobattistela and others added 4 commits October 22, 2026 18:11
…hter comments

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
main_pure, taken from #1817, writes a printer of main's type as Bend
source and checks it in a copy of the book; it replaces the descriptor
built by show_main and the C and JS printers that read it. Base gains
U32.hex, Char.quote, String.quote, F32.show.dot, Array.write and
Array.show. lay_eq walks the layout DAG (also from #1817): the printer's
defs take deep shared layouts, which JSON comparison expanded
exponentially (tests/reg/show_shared_layout.bend took 93 s to build).

comp.ts: 65,880 -> 65,414 ttok.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Lorenzobattistela Lorenzobattistela self-assigned this Oct 22, 2026
A printer is @unsafe, so the printers of types that hold each other (a
Rose through its List, mutually recursive datatypes) can call each other;
before, the printer written first named one checked later, a dead claim.
An Array's element type is a closed ~ argument: one that depends on a
field is refused, and the printer's locals are renamed past the names in
its text, so a def named x or s stays the user's. The Data-kind check
runs on the book's copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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