Skip to content

Index style rules by their rightmost simple selector - #4163

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:css-rule-indexing
Jul 29, 2026
Merged

Index style rules by their rightmost simple selector#4163
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:css-rule-indexing

Conversation

@vogella

@vogella vogella commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

computeStyle tested every selector alternative of every rule against every element, the main cost of a theme swap. A new RuleIndex buckets each alternative by the id, class, or element type its rightmost compound requires (universal, attribute-only and pseudo-only alternatives go into a remainder bucket consulted for every element), and the matcher now runs only on the candidates an element can possibly match, in unchanged cascade order. Styling results are identical: match positions are preserved, and the new RuleIndexTest locks the invariant that the index never drops an alternative the matcher would accept, checked over a stylesheet covering every selector shape.

Measured with a workbench theme-swap benchmark (20 editors, about 4000 widgets, 5 warmup and 10 measured swap rounds per direction), engine applyStyles time falls from 177.4 to 155.8 microseconds per call and from 3018 to 2651 ms per swap, about 12 percent less styling work per theme change. The applyStyles call count is identical at 17013 per swap, which confirms the styling behaviour is unchanged.

An earlier revision of this description quoted 21 percent. That figure was measured against a baseline predating #4160, and master has since become about 20 percent faster on this benchmark on its own, so the remaining gain from rule indexing is smaller. The numbers above were re-measured against current master.

Follow-up to #3980.

vogella added a commit to vogella/eclipse.platform.ui that referenced this pull request Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Test Results

   858 files  + 3     858 suites  +3   54m 17s ⏱️ - 1m 50s
 8 124 tests + 4   7 881 ✅ + 4  243 💤 ±0  0 ❌ ±0 
20 274 runs  +12  19 620 ✅ +12  654 💤 ±0  0 ❌ ±0 

Results for commit cc8feb0. ± Comparison against base commit 86e17df.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the css-rule-indexing branch 2 times, most recently from 1a0170a to bb6da72 Compare July 6, 2026 10:13
@vogella vogella mentioned this pull request Jul 28, 2026
@vogella
vogella force-pushed the css-rule-indexing branch from bb6da72 to 955d9a4 Compare July 28, 2026 10:20
@vogella
vogella marked this pull request as ready for review July 28, 2026 10:21
@vogella

vogella commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Re-measured against current master, since the figure in the original description was taken before #4160 and #4161 landed.

Three runs back to back in one session, same machine, same reactor, each tree differing only by the commit under test. Benchmark is a workbench theme swap with 20 editors and about 4000 widgets, 5 warmup and 10 measured rounds per direction.

tree engine applyStyles per call per swap applyStyles calls per swap
baseline predating #4160 222.61 us 3787 ms 17013
current master 177.38 us 3018 ms 17013
current master + this PR 155.80 us 2651 ms 17013

So this PR is worth about 12 percent on top of current master. The originally quoted 21 percent was measured from the older baseline; master itself got roughly 20 percent faster in between, so the same code now starts from a lower number.

Wall clock moves less, since paint and layout dominate a swap: dark swap median 3219.79 to 3094.57 ms, light swap median 3017.48 to 2927.00 ms, dark p95 3621.64 to 3175.38 ms.

The applyStyles call count is identical at 17013 per swap and 340260 in total across all three runs, which is a useful check that the index changes which rules are tested and not which ones match.

Two caveats for anyone reproducing this. Absolute microsecond values drift between sessions, the same pre-#4160 tree measured 196.60 us in an earlier run and 222.61 us now, so only within-session pairs are comparable. And the accumulated engine time counts nested applyStyles calls more than once, so the per-swap figure is a relative metric and not a share of wall-clock swap time.

computeStyle tested every selector alternative of every rule against
every element. RuleIndex buckets each alternative by the id, class, or
element type its rightmost compound requires; alternatives without such
a key (universal, attribute-only or pseudo-only compounds) go into a
remainder bucket consulted for every element. A lookup gathers the
buckets the element satisfies and hands the candidates to the matcher
in cascade order, so match positions and cascade results are unchanged.
RuleIndexTest locks the completeness invariant: over a stylesheet
covering every selector shape, the index never drops an alternative the
matcher would accept.
@vogella
vogella force-pushed the css-rule-indexing branch from 955d9a4 to cc8feb0 Compare July 28, 2026 15:30
@vogella
vogella merged commit 4cc7bb9 into eclipse-platform:master Jul 29, 2026
18 checks passed
@vogella
vogella deleted the css-rule-indexing branch July 29, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant