Skip to content

Studio: load long chat history faster on Linux by mounting parked history in larger steps - #16924

Merged
danielhanchen merged 2 commits into
mainfrom
studio-webkitgtk-history-load
Nov 6, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-webkitgtk-history-load

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #16854. On the Linux desktop app (WebKitGTK), loading a long chat's history became about 60 to 80% slower after #16854, because history was mounted 2 messages per frame for the whole thread (about 142 commits instead of about 9 for a 150-turn chat). The first messages appeared at the same time; the extra time was the background history load, with about 150 frames over 50 ms instead of about 30.

Fix

WebKitGTK only. Each widening step measures how far the first mounted row is above the viewport top (read after the existing anchor capture, so no extra layout pass):

  • Within the window controller's reach (2000 px), rows stay unparked and can move what the reader sees, so they still mount 2 per step, as in Studio: reduce long-chat panel and scrolling lag on Linux #16854.
  • Past it, rows are parked as they land, so the step ramps 2, 8, 16 and holds at 16 (FAR_MOUNT_CHUNK). The first step of every load stays at 2 so the tail paints as early as before.
  • Coming back within reach drops straight to 2. Pausing during scroll, typing and pointer drags, flushSync, and the anchor correction are unchanged.

Chromium (Windows) and macOS never call the new path; their step stays CHUNK_MESSAGES.

The cap is 16 rather than 32 on purpose: 32 brought the load time back to within 2 to 6% of before #16854 with Glass off, but made single frames up to about 1.4 s on CPU-painted WebKit. 16 keeps the worst frame at the level of the 2-per-step loader.

Results

GitHub ubuntu-latest, Playwright WebKit, 150-turn heavy chat, time until all 300 messages are mounted, per-runner medians of 3 loads (two runners of different speed):

Before #16854 main This PR
Glass off, runner a 13.6 s 21.3 s 15.1 s
Glass off, runner b 8.1 s 13.2 s 9.2 s
Glass on, runner a 14.4 s 24.5 s 17.0 s
Glass on, runner b 8.5 s 15.6 s 10.2 s
  • First messages appear on the same frame as main (the first step is 2 rows on both).
  • No reader shake: the message at the middle of the viewport did not move by 1 px or more in any load, the same as main.
  • Chromium loads identically to main (all 300 messages at 5.6 s, 32 per step in both).

Tests

  • progressive-mount-controller.test.ts: the step stays small near the reader and for unknown geometry, ramps 2, 8, 16 past the reach and holds, drops back when the reader returns, never changes the step on other engines, and covers a 300-message thread in about 20 commits instead of about 142.
  • Glue tests pin that only WebKitGTK takes the adaptive step.
  • 72 related tests pass; tsc -p tsconfig.app.json and node scripts/typecheck.mjs --tests are clean.

Full history on a long thread took about 60% longer to mount on WebKitGTK
after the two-message steps: each widening commit has a fixed cost, and a
300-message thread needed about 142 of them.

Keep the two-message step while the prepend frontier is within the message
window's reach of the viewport, where new rows stay unparked and can move
what the reader sees. Past it rows are parked as they land, so grow the step
fourfold per frame up to CHUNK_MESSAGES. Other engines keep CHUNK_MESSAGES.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T17:35:58.551885Z
We couldn’t complete this review. Comment @codex review to try again.
a153249 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 6, 2026
@danielhanchen
danielhanchen merged commit e94f007 into main Nov 6, 2026
@danielhanchen
danielhanchen deleted the studio-webkitgtk-history-load branch November 6, 2026 18:09
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