Skip to content

perf(web): cheaper key frames and long lines on Safari - #37

Open
SectionTN wants to merge 5 commits into
mainfrom
perf/web-rows-and-long-lines
Open

SectionTN wants to merge 5 commits into
mainfrom
perf/web-rows-and-long-lines

Conversation

@SectionTN

Copy link
Copy Markdown
Owner

four speedups for typing on the web. the numbers in 1 to 3 are desktop Chrome at 8x CPU throttle:

  1. every edit rebuilt the layout's row starts to the end of the document, 20 ms of handler time over 60 keys on a 10k-line file. the layout keeps a running row total now and extends the row starts only as far as a lookup needs. this one is in the shared C++ core, so Android and iOS get it too.
  2. syncScroll wrote both scroll axes whenever a reveal moved either one, and every scroll write makes the browser lay the page out, 18 ms over 60 keys of a 300-line file. an axis that matches the position the draw last read or wrote is left alone now.
  3. a typed letter rebuilt every span of its line, so measuring the line's width redid the whole line: prepare took 102 ms over 60 keys of a 300-line file. a line whose runs keep their count and styles only gets new text in the nodes that changed.
  4. a minified file with no language was one text node of the whole line, and WebKit spends time on a Range in proportion to its node, about 0.35 s a key on a 2M-character line. runs longer than 4096 units split into text nodes now, after a space or punctuation near the limit, and the same line draws in about 100 ms, as in Chromium.

with the first three, 300 lines at 8x had key work p95 of 6.5 to 7.7 ms against an 8 ms gate.

Every edit marked the row starts dirty from the edited line, and the
content height then rebuilt them to the end of the document: 20 ms of
handler time over 60 keys on a 10k-line file at 8x CPU throttle. The
layout now keeps a running row total and extends the row starts only as
far as a lookup needs.
A scroll write makes the browser lay the page out at once. syncScroll
wrote both axes whenever a reveal moved either one, 18 ms over 60 keys
of a 300-line file at 8x CPU throttle. It now leaves an axis alone when
it matches the position the draw last read or wrote.
A typed letter rebuilt every span of its line, so the forced layout that
measures the line's width redid the whole line: prepare took 102 ms over
60 keys of a 300-line file at 8x CPU throttle. A line whose runs keep
their count and styles now only gets new text in the nodes that changed.
A minified file is one line, and with no language it was one text node
of the whole line. WebKit spends time on a Range in proportion to its
node, so every caret and selection rect cost about 0.35 s a key on a
2M-character line. Runs longer than 4096 units now split into text nodes,
after a space or punctuation when one is near the limit, and the same
line draws in about 100 ms, as in Chromium.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: effbfe11-cdcc-4b91-8fb4-41fac7924919
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

On Linux CI, WebKit painted a six-column selection across two text nodes as
53 px against 51 px for the same columns measured in one range, because each
piece's rect rounds out to whole pixels. The check now allows one pixel for
every painted piece.

This branch has not been deployed

No deployments
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