Skip to content

perf(octane): register compiler commit writers by cell - #2095

Merged
trueadm merged 1 commit into
octanejs:nextfrom
openai-oss-forks:codex/next-commit-plan-cells
Oct 15, 2026
Merged

trueadm merged 1 commit into
octanejs:nextfrom
openai-oss-forks:codex/next-commit-plan-cells

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Register commit-writer factories at their compiler-assigned cell index. This removes a linear duplicate search for every writer and the later tuple sort while preserving first-writer wins, numeric cell order, and deferred factory execution.

Validation

  • pnpm format:check (scoped format check passed)
  • pnpm typecheck (scoped typecheck passed)
  • pnpm test (full workspace suite not run locally)
  • targeted tests: 36 commit-function tests passed across development and production compile modes. Suppressing cell 0 made the dropped-transition DOM test fail, and the restored source passed it.
  • Perf review: scan found zero candidates. This is compiler bookkeeping per template writer; it creates no runtime path, field, DOM operation, or scheduling change. Client/server output was byte-identical for 54 outputs from 27 authored and boundary fixtures, including the repository codegen corpus; no compiler throughput claim is made.
  • Concise-code: compiler source +3/−2; direct cell indexing removes tuple allocation, repeated lookup, and sorting. A Map would preserve insertion order rather than the required numeric cell order. Independent complexity review found no remaining unjustified complexity.

Risk / follow-ups

The output-equivalence corpus is representative, not exhaustive; current-head CI supplies broader coverage.

Provenance

  • An agent produced this diff (agent-authored)

Codex task · host com-79386.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Note

Low Risk
Compiler-only bookkeeping with no runtime output path changes; behavior is intended to stay byte-identical aside from removing O(n) registration work per writer.

Overview
perf(octane): Commit-plan writer registration now stores each factory at its compiler cell index (writes[cell] ??= make) instead of appending [cell, make] tuples and scanning for duplicates.

When emitting the commit function, the compiler walks that structure in index order and invokes factories—dropping the previous sort-by-cell step—while keeping first-writer-wins semantics and deferred make(commit.size()) execution. A patch changeset documents the octane release note.

Reviewed by Cursor Bugbot for commit aa79387. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Oct 15, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 15, 2026 14:56
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares c4cbd556e, the merge commit's first parent with 2e9c591d9 on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

All 20 timed operations (20 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 6.567 6.142 +1.4% −12.8% … +19.6% ⚪ within noise
octane-tsrx replace 13.167 13.317 −6.7% −17.6% … +10.1% ⚪ within noise
octane-tsrx add 4.200 4.075 −5.0% −16.6% … +2.7% ⚪ within noise
octane-tsrx update 0.155 0.151 −4.5% −12.4% … +0.7% ⚪ within noise
octane-tsrx select 0.010 0.010 +6.7% −1.1% … +9.5% ⚪ within noise
octane-tsrx swap 0.035 0.037 −0.6% −9.4% … +6.4% ⚪ within noise
octane-tsrx remove 0.037 0.033 −4.3% −14.5% … +4.3% ⚪ within noise
octane-tsrx runlots 50.008 48.100 +1.1% −8.8% … +7.1% ⚪ within noise
octane-tsrx select_lots 0.011 0.011 +13.5% −1.7% … +18.3% ⚪ within noise
octane-tsrx clear 61.458 61.692 +3.4% −4.2% … +14.0% ⚪ within noise
octane-jsx run 3.600 3.925 ±0.0% −1.3% … +5.7% ⚪ within noise
octane-jsx replace 10.258 10.642 +2.9% −8.7% … +15.4% ⚪ within noise
octane-jsx add 3.700 3.725 +5.6% +1.2% … +17.3% ⚪ within noise
octane-jsx update 0.200 0.197 −0.8% −4.1% … +4.0% ⚪ within noise
octane-jsx select 0.097 0.096 −1.5% −4.9% … +1.2% ⚪ within noise
octane-jsx swap 0.137 0.145 −3.7% −9.2% … +2.7% ⚪ within noise
octane-jsx remove 0.160 0.152 −2.3% −8.3% … +4.6% ⚪ within noise
octane-jsx runlots 30.050 30.833 −4.4% −11.9% … +6.1% ⚪ within noise
octane-jsx select_lots 0.944 0.981 +1.0% −7.5% … +3.9% ⚪ within noise
octane-jsx clear 59.008 57.850 −1.8% −9.2% … +4.2% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 93 measured values.

Public-import reachability bundles (bytes)

No changes across 123 measured values.

@trueadm trueadm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. This is compiler bookkeeping only: the compiled output is the same and the work is linear.

Correctness. writes[cell] ??= make keeps first-writer-wins, which the old some(...) check provided. Iterating the sparse array in index order reproduces the old numeric sort without allocating tuples or sorting. The undefined skip in emitCommitFunction handles holes, and writes.length === 0 still means "no writes", since any registered cell makes the length non-zero. Every commit.write call site (compile.js ~31366, ~31434, ~31450) passes a numeric cell index, so no non-index key can silently fall out of the iteration. reset() reassigns writes = [], so the sparse array doesn't leak between templates. Factories are still called lazily with commit.size() at emit time.

One small suggestion, not blocking: a one-line comment on write saying cell must be a non-negative integer index would make that assumption explicit for future callers.

Numbers (benchmark on aa79387, run 38755904889):

  • All 64 work counters are unchanged.
  • All 93 application and 123 reachability byte values are unchanged, which confirms byte-identical compiled output across the bench corpus. That matches your 54-output check.
  • All timings are within noise.

CI on the current head is fully green: 30 pass, 6 skipped matrix placeholders.

Reviewed with Claude Code

@trueadm
trueadm merged commit 053f092 into octanejs:next Oct 15, 2026
76 of 80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants