Repository navigation
docs: teach performance audits to reuse stable member reads - #1913
Merged
trueadm merged 2 commits intoOct 8, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
October 8, 2026 16:39
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]>
4 of 7 tasks
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Teach performance audits to spot repeated member reads such as
node.firstChildand shared member-chain prefixes, and reuse stable results in a localconst. 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 syncpnpm rules:checkandpnpm context:budget:checkpnpm format:files:checkandgit diff --check(Markdown is intentionally excluded from Prettier by the repository)pnpm format:check— scoped check used for this documentation-only changepnpm typecheck— not run; no executable code changedpnpm test— not run; no executable code changedperf-review: not applicable; skill documentation only1d19bbe26: 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
agent-authored)Origin: Codex task · implementation host:
com-79386.Need help on this PR? Tag
@codesmith-botwith 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 afirstChildbefore/after example), and documents when not to hoist reads: getters/proxies, evaluation order, DOM/state mutation, loops, and Octane helpers likegetFirstChild. 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.mdand 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.