Repository navigation
Batch of profiling-derived performance optimizations - #570
Merged
tinchox5 merged 9 commits intoNov 18, 2026
Merged
Conversation
Only elements that a rule, attribute or UA style makes scroll containers can hold a scroll offset, so the memo's scroll walk now queries a selector of those instead of visiting every element. Chrome 157, first capture of 5,200 elements: -8.5 ms (-4%). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y property A tag's defaults were read for all ~440 properties, though only the capture's universe is compared. They are now read for the universe, and for any other property on its first miss. Chrome 157, first capture of 5,200 elements: -8.4 ms (-5%). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er rule Protecting inline styles from retained author rules ran one querySelectorAll per rule. The selectors are now joined into one list and tested once per element with a style attribute. Chrome 157, later capture with a 1,200-rule <style>: -3.1 ms (-4%). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without a property universe, as under an unreadable cross-origin sheet, the full read walked each computed style by index, which in Chrome costs about as much as reading the value. Every element lists the same properties, so the read now goes by name through one list. Chrome 157, first capture of 5,200 elements with a cross-origin font sheet: -32.2 ms (-13%). Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ull scroll walk Without the scroll gate, the memo's walk made up to six layout reads per element. Chromium now checks computed overflow first, which rules out most elements. Firefox reads layout faster, so it and Safari keep the layout reads. Chrome 157, first capture of 5,200 elements: -4.0 ms (-3%). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without a pseudo universe, a pseudo-element's snapshot walked its computed style by index, custom properties included. It now reads the element snapshot's list by name. Chrome 157, first capture of 300 items with ::before/::after icons and a cross-origin font sheet: -39.0 ms (-21%). Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e next Each capture that reached interning parsed every author <style> in the clone for its selectors. The last capture's results are now kept by style text, so only new text is parsed. Chrome 157, later capture with a 1,200-rule <style>: -3.8 ms (-5%). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…content A ::before/::after without content has no box, yet any rule on one gated the probe, so the common `*, ::before, ::after` reset probed every element twice. Only rules that set content, all, an animation or a transition gate it now, and rules with nested rules. The SVG loses some `data-snapdom-has-*` marks; the pixels are the same. Chrome 157, first capture of 5,200 elements under a box-sizing reset: -6.1 ms (-4%). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…walks The safety scan before a memo capture already lists the open shadow roots, yet captures walked the subtree for them again. A root attached during a capture is now found by the next capture's scan, which invalidates the memo as the walk did. Chrome 157, first capture of 5,200 elements: -1.2 ms (-1%). Co-Authored-By: Claude Opus 5.5 <[email protected]>
tinchox5
added a commit
that referenced
this pull request
Nov 18, 2026
Chromium 140 lists only the logical scroll margins, so the key kept scroll-margin-top. ref #570
tinchox5
added a commit
that referenced
this pull request
Nov 18, 2026
Member
|
Thank you!!! This is merged. Here is a dev version with your changes: |
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.
What does this change?
Each commit is an optimization and tests to back it up. Mostly lookup speedups producing identical results, or caching.
<style>'s selectors are cached between captures.::before/::afterare probed only where a rule can give them content (likecontent,all,animation, which can all setcontent), so a*, ::before, ::afterreset done commonly by CSS frameworks is no longer regarded.There are two minor behavioral changes, where a case turned out to be insignificantly rare, so I cut it out (yes, I, as in the human writing this up):
fullReadableProps(style)no longer takes a document argument. To ensure that it doesn't become an issue, a test now asserts that an iframe’s document lists the same properties as the top one.:host { overflow }anymore. A host that scrolls only through such an internal rule (by changing itsscrollTop) is no longer sampled for a scroll written in the same task as a capture. A scroll event, however, still marks the memo dirty. The invalidation matrix already sends closed roots toinvalidate: true, so it has no new row.Why?
On my setup, a first capture of a 5,200-element page took 163 ms in Chrome. These changes take 25 ms off, and 47 ms when a font sheet from another origin can't be read.
In Firefox it takes 14 ms off 196, and 21 ms with that font sheet.
Browser versions used for measurements: Chrome 157, Firefox 160
Checklist
AI
If you did:
Each commit, paired A/B in Chrome
Fresh context per sample, 16 rounds (32 for the match, the overflow precheck, the pseudo gate and the shadow roots), median of paired differences, 1280×800 at DPR 1. A later capture follows a one-word text change.
::before/::aftericons, font sheet from another originWhole branch on the 5,200 elements: -25.1 ms of 163.0 first, -16.2 of 79.1 later; with the font sheet from another origin, -47.5 of 253.6 first and -17.8 of 108.1 later.
In Firefox (Zen, same harness, 16 rounds, the display's DPR of 1.25): -14.0 ms of 195.5 first and -13.0 of 91.5 later; with the font sheet, -21.0 of 256.0 first and -12.5 of 123.0 later. The full read by name alone takes 17 ms off that first capture and adds about 3 ms to the later one there.
Demo
After
npm run compile, put this in the repo root and serve the root. Each load prints its first capture; compare main'sdistwith this branch's. Without the<link>, every sheet is readable and the other commits apply.In Chrome at 1280×800 (median of 8 loads), main took 554 ms and this branch 412 ms; without the
<link>, 230 and 203 ms.