Skip to content

perf: reuse staged transition updates - #947

Merged
domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:codex/perf-transition-bookkeeping
Sep 3, 2026
Merged

domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:codex/perf-transition-bookkeeping

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Reuse staged transition update records instead of looking them up again in state/reducer setters and profiling paths. Batch selection stays after user updater code, preserving reentrant Actions and owner-render queue replay.

This builds on the transition ownership implementation merged in #949. Add eight behavioral cases covering nested and overlapping owners, held Suspense content, partial unmount, rejection recovery, and an updater that starts an Action. Extend the existing transition-hooks benchmark with seven native Map.get work guards.

Performance evidence

Compared with main 613508303, using the same production fixture, compiler, dependencies, and 64-cycle phases:

Phase Map.get before Map.get after
Replacement transition 832 768
Functional updater transition 832 768
Suspended hold and release 1,793 1,729
Urgent update beside a transition 1,536 1,472
Ordinary dispatch control 256 256
Eager bailout control 0 0
Delegated click control 3,392 3,392

This removes one lookup per staged update in the measured phases. Counts cover the complete workload, including DOM/harness calls, and are separate from timing. All existing creation counters and semantic observations remain identical. The combined minified bundle shrinks by 15 bytes (203,020 → 203,005); gzip changes by +1 byte (64,354 → 64,355) and compiled fixture size remains 3,368 bytes.

Historical quiet A/B/B/A timings against eff02711b, before the final main refresh, used the existing Node/happy-dom settings. The current-base revalidation repeated deterministic counts and bytes only. Functional-updater mean/median times (µs) were A1 1.753/1.583, B1 2.041/1.967, B2 1.674/1.562, A2 1.648/1.555. The first candidate run also slowed the unchanged click control (5.821 → 7.701 → 5.813 → 5.607 µs). All four runs passed semantic and counter gates; variability prevents attributing elapsed-time differences to this change. No elapsed-time improvement is established.

Validation

  • Before the final main refresh, all 16,286 core dev/prod/profile tests passed across 942 files on d38d2f053 (vitest run --project octane --project octane-prod --project octane-profile --maxWorkers=8).
  • After merging 613508303, all 622 targeted transition/linked-state/profiling, form-action, audit, and SSR tests passed across 38 files; core typechecking passed. The prior revision also passed all 46 MCP tests locally and every CI check.
  • The eight new cases also passed against baseline eff02711b. Deliberately selecting the batch before the updater makes both dev/prod reentrancy cases fail; restored the candidate byte-for-byte and reran the full suite successfully.
  • All 42 transition-hook ratio guards pass. Main fails the four intended lookup guards while passing the 35 pre-existing guards and three controls.
  • Core TypeScript check, strict new-fixture/test TSRX check, scoped formatting, diff checks, and pnpm sync passed.
  • Full repository tests/typechecks/format were not run locally; current-head CI is tracked below.
  • CI: all checks passed for final head cf93895ac, including core test shards, React parity, website/browser integration, lint, typechecking, examples, package validation, and provenance. Bugbot completed with no issues. The branch includes live main 613508303 and GitHub reports no conflicts; human review is still required.

Risk / follow-ups

The runtime changes only internal staged-record plumbing. The new Map.get census restores the native method in finally, and timing remains uninstrumented. Lookup counts are deterministic work evidence, not retained-memory or application-latency measurements. No public API changes.

Provenance

  • An agent produced this diff (agent-authored)

Note

Low Risk
Internal transition staging plumbing only; batch selection still runs after user updaters, with new behavioral tests and deterministic benchmark guards limiting regression risk.

Overview
stageTransitionValue now returns the staged TransitionActionUpdate (or null) instead of a boolean, so state, reducer, and profiling paths reuse that record instead of calling batch.updates.get(slot) again after staging.

The transition-hooks benchmark gains an untimed Map.prototype.get census during observed drives, seven _map_gets ratio guards in ratios.json, bundle_minified reporting, and timing that runs before any native override. Docs record one fewer lookup per staged-update cycle with unchanged creation semantics.

Eight new transition ownership tests (fixture + transition-ownership.test.ts) cover overlapping useTransition owners, held Suspense, partial unmount, Action rejection, and starting an Action from a functional updater.

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


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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent perf PR: performance work labels Sep 3, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 3, 2026 21:04
@domgan-oai domgan-oai changed the title perf: reduce transition owner allocations and update lookups perf: reuse staged transition updates Sep 3, 2026
@domgan-oai
domgan-oai merged commit 0705d6c into octanejs:main Sep 3, 2026
32 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