Skip to content

perf: reuse keyed-list chain on first-fill unwind - #1006

Merged
domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/reuse-linear-list-chain-981
Sep 9, 2026
Merged

domgan-oai merged 1 commit into
octanejs:mainfrom
openai-oss-forks:codex/reuse-linear-list-chain-981

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Reuse the keyed list's existing sibling chain to unwind a completed first-fill prefix after a later row throws or suspends. This removes the mounted array and its per-row push from the successful 0→N path. Part of #981.

Why

Each completed row is already linked to its predecessor. The previous implementation kept a second array only to traverse those rows backwards in the exceptional cleanup path.

Changes

  • Walk prevSibling backwards on failure, saving the predecessor before unmount; preserve the existing map deletion, warm-memo retention, DOM detachment, and list-state reset.
  • Cover a key getter error, a subsequent suspension and retry, detached aborted nodes, and survivor identity after reorder in a small keyed list.
  • Add an octane patch changeset.

Validation

  • pnpm format:check (not run; changed-file check below)
  • pnpm typecheck
  • pnpm test (not run; targeted suites below)
  • targeted tests: pnpm exec vitest run packages/octane/tests/for.test.ts --reporter=dot (176/176 in development and production); pnpm exec vitest run packages/octane/tests/hydration/for-hydrate.test.ts packages/octane/tests/hydration/emptyfor-hydrate.test.ts packages/octane/tests/hydration/descriptor-list-hydrate.test.ts --reporter=dot (54/54)
  • The new regression failed in both builds when the first-fill cleanup loop was deliberately disabled, then passed with the implementation restored.
  • pnpm format:files:check packages/octane/src/runtime.ts packages/octane/tests/for.test.ts .changeset/reuse-linear-list-chain.md; git diff --check; pnpm sync

Production source bundles from the same esbuild 0.28.1 toolchain changed from 352,272 to 352,247 raw bytes (110,542 to 110,522 gzip). A public createRoot/createElement generic keyed component list preserved the 256-row output hash and survivor DOM identity. In nine paired rounds of 16 first-fill/clear cycles, medians were 20.6454 → 20.6623 ms in baseline-first order and 22.1264 → 22.0019 ms in candidate-first order. Timings overlap and do not establish a throughput gain; the deterministic change removes one throw-only array and 256 pushes from that workload.

The configured Secretive signing agent refused two signing attempts. GitHub main branch protection does not require signed commits, so this PR's commit is unsigned.

Risk / follow-ups

The cleanup path now follows the same backward link pattern already used by the certified host-only mount path. It saves each predecessor before unmount to withstand link changes during teardown. Larger first-fill timings were GC dominated and not usable as performance evidence.

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.

@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 23:01
@domgan-oai
domgan-oai merged commit 31aff05 into octanejs:main Sep 9, 2026
48 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