Skip to content

perf: initialize client block fields once - #989

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/declare-core-block-fields-981
Sep 8, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/declare-core-block-fields-981

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Make BlockImpl, ScopeImpl, and LiteBlockImpl field declarations type-only; their constructors remain the single source of runtime field initialization.
  • Preserve the existing own-property order by keeping createdStamp last on blocks and slots last on scopes.

Why

With native class-field semantics, the previous declarations defined 70 properties as undefined before the constructors assigned their values. That work occurs for every client block, keyed row, and child scope. It also generalized several numeric fields during warm-up.

Changes

  • Replace uninitialized field declarations with declare in the three runtime classes, retaining every constructor assignment and field.
  • Add a public mount/hydration/keyed regression for nested hookless scopes, row identity/state, ref cleanup, and server-node adoption.
  • Add an octane patch changeset.

Validation

  • Source-only public fixture mount and hydration pass; deliberately omitting LiteBlockImpl.parentNode initialization makes the same mount fail at the DOM insertion boundary.
  • Exact-class esbuild/V8 probe: emitted undefined field definitions 70 → 0 (Block 52, Scope 13, Lite 5); all 53/13/5 own properties, key order, fast-property status, and per-class instance maps match baseline.
  • Same-environment source-only Chromium 149 keyed mount, eight ABBA paired cycles with exact DOM/order/identity/unmount controls: 1,000 rows median 1.30 → 1.10 ms; 10,000 rows 10.55 → 9.00 ms. These timings are directional because within-run variation overlaps the delta; this is not a canonical compiled js-framework result.
  • Same-esbuild production full-index bundle: 344,044 → 343,279 raw bytes; 108,478 → 108,248 gzip bytes.
  • Cached Prettier check on changed files, esbuild TypeScript parse, and git diff --check.
  • Current-head CI: all 26 jobs passed, including the new regression in both octane and octane-prod (3 tests each), Chromium integration, parity, lint, typecheck, and provenance.
  • Local pnpm sync and pinned Vitest/typecheck could not start: frozen install returned 403 for @tsrx/[email protected], and the sync preflight returned 403 for @tsrx/[email protected].

Risk / follow-ups

Native field definitions previously shadowed deliberately installed setters on internal class prototypes; constructor assignments can invoke such setters. No supported API promises prototype mutation of framework-owned Blocks/Scopes. The source-only mount timings need corroboration by the compiled benchmark before any broad speed claim.

Refs #981.

Provenance

  • An agent produced this diff (agent-authored)

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


Note

Medium Risk
Touches the hot-path client runtime object layout; behavior is guarded by new mount/hydration tests, with a noted edge case if prototype setters were installed on framework-owned block/scope classes.

Overview
Runtime object construction no longer emits native class-field initializers for BlockImpl, ScopeImpl, and LiteBlockImpl. Uninitialized instance fields are now declare (type-only), so each new block/scope/lite proxy is shaped only by the existing constructor assignments—avoiding dozens of redundant undefined definitions per allocation under native class-field compilation while keeping the same fields and V8 hidden-class intent.

Property order is explicitly preserved: createdStamp stays last on blocks and slots last on scopes (constructor assignment order adjusted where needed).

Regression coverage adds component-mount-shapes.test.ts for nested hookless children (DOM identity, ref detach), keyed vs sibling identity, and hydration adopting server nodes without replacement. An octane patch changeset documents the change.

Reviewed by Cursor Bugbot for commit 8d907d4. 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 Sep 8, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 8, 2026 08:56
@domgan-oai
domgan-oai merged commit c9447c3 into octanejs:main Sep 8, 2026
51 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.

1 participant