Skip to content

Website: make switching selectors fast - #2491

Merged
alexey-milovidov merged 1 commit into
mainfrom
faster-selectors
Oct 9, 2026
Merged

alexey-milovidov merged 1 commit into
mainfrom
faster-selectors

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

Switching selectors on the benchmark pages (main, hardware, versions) had a noticeable lag: every click rebuilt the whole "Detailed Comparison" table (20k–75k cells), and the browser spent most of the time laying it out.

Changes

  • Virtualized details table. Column widths and row heights are measured once, on a table holding all header cells plus a single row of the widest cells. They are then fixed (table-layout: fixed + <colgroup>). Only the cells within a screen of the viewport are rendered, and the edges are updated incrementally while scrolling. Widths are measured again when web fonts finish loading.
  • Deferred rebuild. The details table is rebuilt right after the summary is painted, so the click responds immediately. If the page is scrolled before that, it is rebuilt synchronously, so outdated data is never shown.
  • No forced synchronous layouts. textContent replaces innerText in selector loops. --qn-left on the versions page is no longer rewritten (and the table no longer re-measured) on every render.
  • Cheaper computations. Per-cell baseline computations are hoisted out of loops, and selectRun on the versions page is cheaper.

Measurements (headless Chromium, 1600×1000)

Main Hardware Versions
Selector click (median), before → after ~510 → ~80–100 ms ~245 → ~55–75 ms ~1250 → ~100–165 ms
Click while viewing the table 453 → 123 ms 276 → 87 ms 1323 → 192 ms
Longest blocking task 509 → 107 ms 464 → 227 ms 1591 → 121 ms
Worst frame scrolling to the table — — 31–35 ms on all pages

Verification

  • Screenshots of the old and new pages were compared across all three pages: metric switches, selector toggles, "nothing selected" and back, and many horizontal and vertical positions inside the table, reached both by jumping and by scrolling gradually. All 110 screenshots are pixel-identical.
  • The summary after toggling query checkboxes inside the table is identical to the old version.
  • No JS errors.

Trade-offs

  • Off-screen cells are not in the DOM, so the browser's find-in-page does not find values in the details table until they are scrolled into view.
  • The worst frame while scrolling fast inside the versions table went from 55 to 69 ms. The median went from 35 to 19 ms.

🤖 Generated with Claude Code

Every click on a selector rebuilt the whole "Detailed Comparison" table
(20k-75k cells), and laying it out took most of the time: ~0.5 s per click
on the main page, ~0.25 s on the hardware page, ~1.3 s on the versions page.

- The details table is virtualized: column widths and row heights are
  measured once on a table with all header cells and a single row of the
  widest cells, then fixed; only the cells within a screen of the viewport
  are rendered, and the edges are updated incrementally while scrolling.
  The widths are measured again when web fonts finish loading.
- The details table is rebuilt after the summary is painted, so the click
  responds right away; a scroll before that rebuilds it immediately.
- Avoid forced synchronous layouts: textContent instead of innerText for
  the selectors, and don't rewrite --qn-left on the versions page unless
  it changes.
- Hoist per-cell baseline computations out of loops; cheaper selectRun on
  the versions page.

The rendering is pixel-identical to the previous version.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Preview of the main benchmark page from this PR: index.html at ac177c8 with the current results embedded.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Yes, it is faster.

@alexey-milovidov
alexey-milovidov merged commit 6804176 into main Oct 9, 2026
3 checks passed
@alexey-milovidov alexey-milovidov self-assigned this Oct 9, 2026
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