Skip to content

docs: teach performance audits to reuse stable member reads - #1913

Merged
trueadm merged 2 commits into
octanejs:mainfrom
openai-oss-forks:docs/performance-member-access
Oct 8, 2026
Merged

trueadm merged 2 commits into
octanejs:mainfrom
openai-oss-forks:docs/performance-member-access

Conversation

@domgan-oai

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

Copy link
Copy Markdown
Contributor

Summary

Teach performance audits to spot repeated member reads such as node.firstChild and shared member-chain prefixes, and reuse stable results in a local const. Include a before/after example, mutation and evaluation-side-effect boundaries, and guidance to preserve Octane's DOM access helpers.

Require emitted/minified size and relevant runtime evidence before claiming savings. Update the canonical RuleSync skill and all five generated copies.

Validation

  • pnpm sync
  • pnpm rules:check and pnpm context:budget:check
  • pnpm format:files:check and git diff --check (Markdown is intentionally excluded from Prettier by the repository)
  • Skill-creator validation of the generated Codex skill; all five generated bodies match the canonical source
  • Independent read-only review: no actionable semantic or complexity findings
  • pnpm format:check — scoped check used for this documentation-only change
  • pnpm typecheck — not run; no executable code changed
  • pnpm test — not run; no executable code changed
  • perf-review: not applicable; skill documentation only
  • Current-head CI for 1d19bbe26: run 37810556895, attempt 2 passed. Reran the failed/cancelled test jobs after an unrelated 5-second TanStack Query Devtools import-test timeout; no test or runtime code changed.

Risk / follow-ups

Local sync used isolated generator dependencies with Node 24.19.0, cached pnpm 12.8.2, RuleSync 8.32.0, and Prettier 3.9.9. The registry did not provide pinned pnpm 12.9.1 or the TSRX Prettier plugin 0.6.3, so the available plugin 0.5.2 was used locally. Sync produced no unrelated changes; repository dependency manifests and lockfiles are unchanged. This PR changes audit guidance and makes no measured runtime or size claim.

Provenance

  • An agent produced this diff (agent-authored)

Origin: Codex task · implementation host: com-79386.


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


Note

Low Risk
Documentation-only updates to agent skills; no runtime, compiler, or bundle behavior changes.

Overview
Extends the performance-audit agent skill so audits explicitly cover repeated member reads in hot paths and emitted JS.

A new hot-path discipline bullet points reviewers at a Reuse stable member reads section. That section recommends caching stable values in a local const (with a firstChild before/after example), and documents when not to hoist reads: getters/proxies, evaluation order, DOM/state mutation, loops, and Octane helpers like getFirstChild. It also requires emitted/minified size and owning benchmarks before claiming wins.

The same text is applied to the canonical .rulesync/skills/performance-audit/SKILL.md and the five generated copies under .agents, .claude, .cursor, .gemini, and .github.

Reviewed by Cursor Bugbot for commit 1d19bbe. 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 docs PR: documentation only labels Oct 8, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review October 8, 2026 16:39
@trueadm
trueadm merged commit 4224a4a into octanejs:main Oct 8, 2026
72 of 76 checks passed
trueadm added a commit that referenced this pull request Oct 8, 2026
…tion paths (#1904)

Apply performance-audit's "Reuse stable member reads" (#1913) to the code
this PR adds.

- Both adopters' write loops read `next[i]` and `previous[i]` once.
- writeOperation reads `instance.previous[index]` once, after its
  disposed guards.
- writeText no longer reads `region.range` on the unchanged path, and
  caches `range.end` in the branches that use it.
- adoptRegion caches `range.end`.
- resolveFixedNodes destructures its open-children flag rather than
  indexing `descriptor.nodes[i]` again.

Minified adopters shrink by 12–14 B. gzip moves 4–11 B, so this is a
read-count change, not a size claim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm added a commit that referenced this pull request Oct 8, 2026
…1909)

* fix(octane): adopt DOM bindings over browser-translated text leaves (#1904)

Chrome's page translation replaces a text leaf's Text node with nested
<font> wrappers. Fixed and addressed adoption rejected that leaf (#318,
#321), and a leaf translated after adoption silently dropped every later
write, because nodeValue is a no-op on an element.

Adoption now accepts a text leaf whose first child is a <font> element and
writes nothing to it, so the page neither flashes back to its source
language nor shifts. The writer receives the channel's previous value and,
once that value exists, replaces any non-Text leaf content on change. Any
other element in a text leaf still throws.

Document the behavior and the translate="no" opt-out in
docs/deferred-hydration.md, and add a website-only catalog note to #318 and
#321 that never reaches a runtime bundle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(octane): adopt structural binding programs over translated text (#1904)

Structural programs had the same Chrome Translate failure as fixed views.
A static text proof or a text hole whose Text node was replaced by <font>
wrappers failed adoption with #286, and a text hole translated after
adoption silently kept its translation, because writeText set the data of
a detached node.

- resolveFragment accepts a <font> element in a static text slot. The
  marker id already hashes the template source, including that text.
- adoptRegion accepts a <font>-wrapped text hole and records `undefined`.
  The first commit stores the value in a detached Text node and writes
  nothing.
- writeText replaces the range content with its node only when the value
  changes and the node is no longer the range's only child.

Any other element in either slot still throws #286. Extend the
deferred-hydration paragraph and the website-only error note, now also on
#286, to structural views.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): check a text leaf in O(1) and read its nodeValue once (#1904)

Review follow-up. The fixed and addressed resolvers share an isTextLeaf
predicate. It reads firstChild once and uses nextSibling instead of
childNodes.length, which is not O(1).

The fixed-scalar writer reads nodeValue once. A null nodeValue identifies
an element first child, such as Chrome Translate's <font>, so the changed
write no longer reads nodeType.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): validate fixed and addressed binding topology by sibling walk (#1904)

Review follow-up. The element branch of both resolvers still counted live
child lists (`childNodes.length`, `children.length`) and indexed
`children[i]`. In Blink each of those creates a collection and keeps it on
the node.

Each parent now keeps a cursor to its next unclaimed child. Validation
reads `firstChild` and `nextSibling` only, and a final check rejects any
child the server topology does not have. A parent without a cursor
(opaque, text, or not yet visited) claims nothing, which replaces two
explicit parent checks.

Error codes are unchanged for compiler-issued descriptors. New tests pin
#318 and #321 for an extra child, a stray text node, a missing child,
reordered children, and a child under a childless element. Unbound
children still adopt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf(octane): reuse stable member reads in the binding write and adoption paths (#1904)

Apply performance-audit's "Reuse stable member reads" (#1913) to the code
this PR adds.

- Both adopters' write loops read `next[i]` and `previous[i]` once.
- writeOperation reads `instance.previous[index]` once, after its
  disposed guards.
- writeText no longer reads `region.range` on the unchanged path, and
  caches `range.end` in the branches that use it.
- adoptRegion caches `range.end`.
- resolveFixedNodes destructures its open-children flag rather than
  indexing `descriptor.nodes[i]` again.

Minified adopters shrink by 12–14 B. gzip moves 4–11 B, so this is a
read-count change, not a size claim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(octane): accept only a single translated wrapper in a text leaf (#1904)

Bugbot review: isTextLeaf accepted a leading <font> even when other nodes
followed it. Those leaves used to fail #318/#321, and a structural text
hole already requires a single node.

Chrome Translate replaces one Text node with one wrapper, so a text leaf
now holds no child, or exactly one: a Text node or a <font> element. The
negative tests cover a <font> followed by text in every fixed lane, and
two wrappers in an addressed view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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 docs PR: documentation only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants