Repository navigation
perf: trim record/commit codegen boilerplate - #2157
Conversation
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)
3 other measured values are unchanged. Public-import reachability bundles (bytes)
39 other measured values are unchanged. |
…itBag Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website-mcp | becfc77 | Commit Preview URL Branch Preview URL |
Oct 19 2026, 08:37 PM |
The commitStagedBag trampoline and the unconditional setEventSlot call each added production calls per committed bag or handler; js-framework work counters now match the base exactly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
octane-website | becfc77 | Commit Preview URL Branch Preview URL |
Oct 19 2026, 08:38 PM |
domgan-oai
left a comment
There was a problem hiding this comment.
I do not approve this as-is. The code-size result and unchanged work counters are encouraging, and the current checks are green, but the queue now misclassifies some valid non-bag targets. The commit-function sharing also loses source attribution for later templates. Please address the two inline findings before merging.
…lias their origins Co-Authored-By: Claude Opus 5.5 <[email protected]>
A queued DOM element can carry an application's own `$` expando, which the ops loop, its pool return, dropRootOps and dropBodyOps took for a bag. commitQueuedBag marks a bag's entry; the loop inlines it, so the work counters stay at base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#2157 merged into `next` as 32dc7f1 after `next` had already landed on main (#2103), so its compiled-output saving never shipped. Cherry-picked onto main; the one conflict kept main's bagOf rehome argument in the spill path. Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Zero-runtime-cost trims to the record/commit codegen that #2044 added. Each commit function, update branch and hole-aware walk now emits less boilerplate:
nextbase (e326ff4)_$sibling(x)instead of_$sibling(x, 1)(1 is already the default)const _n = _b.next; … _b.$ &= 255;prologue in each_c$N: the runtime clears the staged state and passes the cells, soC(bag, cells, careful)_$bagDone(__s, _b): the commit fn already sits incells[size + 2]3Event-slot commit through one— dropped: it added a production call per changed handler (octane-jsx +20 calls/op)_$setEventSlotcallTotal: 35,424 → 34,457 B gzip (−967 B, −2.7%) on the 16-file
benchmarks/codegen-sizecorpus (client,dev:false,hmr:false, esbuild minify, gzip -9 over the concatenated output). Minified: 138,972 → 132,086 B (−5.0%). Per-file gzip sum: 43,465 → 42,483 B.Changes
runtime/commit.ts/engine.ts/suspense.ts: bagRecord queues(commitQueuedBag, bag). The op's identity is what marks a bag's entry: the ops loop, its catch and pool-return branches,dropRootOpsanddropBodyOpsno longer guess from a target's$field, which a queued DOM element may carry as an application expando (review finding). The loop inlinescommitQueuedBagandbagDoneclears state itself, so a commit costsC's call alone:size = (bag.$ &= BAG_SIZE), thencells[size + 2](bag, cells, careful). Clearing precedes the first setter, so a throwing setter leaves the bag idle. (A called trampoline was smaller but added one production call per committed bag and failed the js-framework work gate.)compiler/compile.js:(_b, _n[, _f])and keep onlylet _v.commitDoneStatementdrops the name.emitCommitFunction, through a placeholder like the bag-locals one, so a duplicate body can reuse an earlier name (ctx.commitFunctions, keyed byastStructuralKey). As with template interning, sharing applies only to production builds (!hmr && !dev && !profile), so dev, HMR and profile builds keep one commit function per template for debugging and source maps. Underinspect, each duplicate's origins are aliased onto the shared function's throughregisterOriginAlias(review finding).siblingCountdrops the default step.view-transition-scope-commit.test.tsgains a case where the scope host carries an application$of 300 or 3 while its marker op and a template bag commit together; the 300 case fails on the previous head, where$became 44.compiler-template-origins.test.tsgains a repeated-binding origin case: inspect leaves the code unchanged, prod aliases the secondtitle={props.value}onto the first, and dev needs no alias.commit-functions.test.tsgains a case where two templates share commit code and a third differs only in its setter. Urgent updates, a dropped transition, and a later urgent update each commit through their own bag.Validation
vitest --project octane --project octane-prod: 46,610 / 46,611 pass on the final head. The 1 failure iscompiler-vite-options"without quadratic comment scans", a 6 s wall-clock assertion on a template-free module, so no commit fns are involved. It fails only under full parallel load and passes when run alone.pnpm typecheckclean;pnpm format:files:checkon changed files clean;pnpm syncproduced no changes.pnpm format:check/ fullpnpm test(left to CI)octane-tsrxfixtures, base = this PR's base built in place, both served statically and run as two TARGETS of each harness, two passes. Median ms, ratio = head/base averaged over passes:fw_*), because the runtime clearing outweighs the compiled savings in these few-template apps. Component-heavy modules gain the corpus savings above. Bytes are report-only; this trade keeps zero added calls.node benchmarks/js-framework/pair.mjs --work-onlyagainst a base checkout of e326ff4: all 40calls_*anddom_*counters for octane-tsrx and octane-jsx are identical to base.perf-review:perf-review-scanreports no candidates. Hot path: no added calls. The property load and state write eachCused to do moved inline into its two callers, and non-bag ops pay onetarget?.$compare, a read the loop's pool-return check already makes. The bag shape is unchanged, there are no new allocations, and the commit fn arity is now 2–3 args, called consistently.concise-code: src +82 −83 (runtime +18 −7). Most of the compile.js diff is the bag-factory call re-indented into afactoryLineclosure. No new files except the changeset, no new exports. Alternatives considered:const _c$5 = _c$3): rejected because it costs bytes per duplicate and keeps the prologue;_vas a spare parameter: rejected as a readability hack worth roughly 60 B.Risk / follow-ups
setEventSlot'sJOURNAL_PROPpush): removing it leaves all of commit-functions and the transition/event suites green. This gap predates this PR, which leaves that path unchanged, but it is worth a test.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches core render/commit paths (bag staging, root ops queue, commit function arity) where setter throws and transition drop semantics must stay correct; behavior is heavily tested but the surface area is security-adjacent DOM consistency rather than auth.
Overview
Shrinks compiled record/commit output (~2.7% gzip on the codegen-size corpus) by moving bag staging cleanup into the runtime and deduplicating identical commit helpers.
Runtime / API shape: Hoisted commit functions are now
C(bag, cells, careful?)with no per-function prologue—the caller clearsbag.$and passes the staged cell array._$bagDone(__s, _b)no longer takes the commit fn; it invokescells[size + 2]like queued commits. Queued bag work uses an explicitcommitQueuedBagop instead of inferring bags fromtarget.$, so DOM nodes with app-owned$expandos are not misclassified.Compiler: Generated
_$sibling(node)omits the second argument when the step is 1. Production builds intern byte-identical commit functions per module (commitFunctions+ structural AST key) and wire bag factories after naming; dev/HMR/profile keep one function per template.commitDoneStatementdrops the commit name argument.Tests cover shared commit code across templates, origin aliasing for deduped commits, and commit-queue behavior when a host element carries
$.Reviewed by Cursor Bugbot for commit becfc77. Bugbot is set up for automated code reviews on this repo. Configure here.