Skip to content

perf: skip warm cache scans in new render episodes - #1024

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/skip-stale-warm-cache-walks-981
Sep 9, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/skip-stale-warm-cache-walks-981

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

  • Skip the ancestor warm-cache scan when the current render episode is newer than every attached cache.
  • Advance one numeric maximum at the existing cache attachment point. Older retries remain eligible; root retry caches and held/promoted transition harvests keep their existing lookup paths.
  • Add behavioral regressions, a production benchmark guard integrated into recursive-context work checks, and an octane patch changeset.

Partially addresses #981's parallel-use warm-plan item. This targets irrelevant adoption scans after prior warming; complex warm-plan allocation and other active-plan traversal work remain separate follow-ups.

Performance evidence

Baseline: merged main 7804852be69a78d11f3dc160f44d3bd358bedfc1. Same production fixture, Node 26.4.0, and Chromium 149.0.7827.55. Detailed Chromium coverage observes the parent-property read in the actual emitted runtime helper, without source probes.

BENCH_JSON=/tmp/warm-adoption.json node benchmarks/recursive-context/warm-adoption-work.mjs
Scenario Memo misses Parent reads before After
Depth 32 mount after unrelated warming 33 1,089 0
Depth 32 update after unrelated warming 33 1,089 0
Depth 128 mount after unrelated warming 129 16,641 0
Depth 128 update after unrelated warming 129 16,641 0

Adoption calls remain 33/129, all memo values and surviving DOM nodes match, and the no-warming control remains at zero adoption calls. A real pending retry retains one adoption, one cache probe, and two parent reads; parent and child resources each start once. The final zero-parent-step guard fails on the untouched baseline. This measures removed lookup work, not an end-user latency improvement.

Validation

  • New dev/prod regressions: 4/4 passed on baseline and final candidate. Omitting marker advancement causes four failures (duplicate request and missing content); using equality instead of <= causes two older-root failures. Both deliberate mutations were restored.
  • Broad Octane suite plus targeted recovery runs: the initial run passed 18,182 tests with 14 expected failures; three compiler cases timed out and 15 browser suites were blocked at launch by the local sandbox. Both compiler files then passed 51/51 with two workers, and all 15 browser files / 130 tests passed with Chromium permissions and two workers. No code changes were needed for these reruns.
  • pnpm typecheck:files packages/octane/src/runtime.ts
  • Scoped pnpm format:files:check for all changed files and git diff --check
  • pnpm sync (no generated changes)
  • Standalone warm-adoption benchmark and complete integrated recursive-context work pass for TSRX/TSX
  • Production async-composition: initialization and transition update each retain eight network starts, eight creators, seven first-wave resources, two dependency waves, and zero mixed states. Existing resource retention, dependent-owner ordering, and lazy-module/node identity gates passed.
  • Full repository pnpm test, pnpm typecheck, and pnpm format:check were not run locally; the core suite and scoped checks above cover the local change. Current-head CI passed all 26 jobs on c176cd00e2fdc01647a3488929003652e1b2efcf (attempt 2). The first attempt hit the same five-second Volar compiler-test timeout; that shard and one canceled shard passed unchanged on rerun. Cursor Bugbot completed successfully with no findings, and there are no review threads to resolve.

Risk / follow-ups

The maximum is never reset or reduced, including when an older root resumes. An outdated maximum can only permit extra scanning; it cannot hide a matching cache. This adds no per-block fields, allocations, retained trees, or cache invalidation hooks. SSR has a separate runtime; client hydration and native resource adoption retain their existing semantics. Independent source review found no correctness issues.

The tests use a retained outer boundary around dynamic content so a root retry cache cannot hide a broken ancestor lookup. Active-plan recording stays intact because earlier completed siblings must still be remembered before later siblings suspend.

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 suspense/memo warm-cache adoption in the client runtime; incorrect episode gating could break retries or duplicate fetches, though tests and benchmarks target those paths.

Overview
Skips pointless ancestor walks when useMemo adoption runs in a render episode newer than every attached warm cache, while still calling adoption itself and leaving root-retry / pending-suspense paths unchanged.

The runtime tracks LATEST_WARM_CACHE_EPISODE when caches attach and gates adoptWarmEntry’s parentBlock loop on CURRENT_WARM_EPISODE <= LATEST_WARM_CACHE_EPISODE, so ordinary sync memos after unrelated warming no longer scan the block chain (thousands of parent steps at depth 128).

Adds a recursive-context warm-adoption benchmark (Chromium precise coverage on adoptWarmEntry, zero parent-step ceiling after priming) wired into bench:work, plus parallel-use regressions for independent async roots alongside ordinary useMemo and sibling resource starts.

Reviewed by Cursor Bugbot for commit c176cd0. 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 9, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 9, 2026 19:49
@domgan-oai
domgan-oai merged commit 4a5edff into octanejs:main Sep 9, 2026
73 of 77 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