Repository navigation
Description
What happened?
In a long chat, opening the thread, switching into it and sending a message all cost main-thread time that grows with the number of messages. The transcript renders every message, and nothing is windowed. With about 300 messages:
- a cold open takes 3.7–5.0 s, against 1.9–2.2 s for a short thread, with one task of 1.4–2.6 s;
- switching into the thread takes 2.1–3.0 s;
- every send freezes the page for 0.5–0.9 s before the first word appears.
Streaming itself and typing in the composer stay smooth.
How it was measured
- Build: main
8b916c0b9, a local production build. Nothing under chat, the shared markdown,packages/ui's markdown, hooks or feedback, or the chat backend changed through1cd6cffba. - Model: the repo's mock gateway (mode A,
lib/mocks), behind a local wrapper that streams long markdown. - Dataset: synthetic. The long thread has 150 turns: 150–300-word markdown replies with lists, a fenced code block in every 4th reply and a table in every 7th. Each reply streams through the real send path.
- Statistics: medians with min–max. "Visible" is the end of the frame that first shows the target.
Run 1 (2 Oct 03:15 occurrence, round r7)
| Flow | Short thread | 300-message thread |
|---|---|---|
| Cold open of the thread URL until every message is in the DOM (n=8) | 2,226 ms (2,136–2,555), 6 messages | 4,156 ms (3,769–5,203), 302 messages |
| …longest main-thread task | 388 ms | 1,830 ms (1,513–1,991) |
| …JS heap / DOM elements after the open | 30 MB / 654 | 83 MB / 14,526 |
| Switch into the thread from the Home panel, app warm (n=6) | 898 ms (821–1,049)* | 2,528 ms (2,334–2,786) |
| …longest task | 868 ms* | 2,018 ms (1,957–2,208) |
| Send → first streamed word painted (n=4) | 486 ms (462–512), 26–32 messages | 995 ms (864–1,304), 322–328 messages |
| …longest task between send and first word | 79 ms | 718 ms (604–915) |
| Typing 30 keys in the composer (n=5) | no key event over 50 ms | no key event over 50 ms |
| During a 600-word streamed reply (n=4) | no task over 89 ms | no task over 63 ms |
*Switching into the short thread from the long one. Its 868 ms task is the long thread unmounting.
Backend path. Seeding the 150 turns through POST /api/app/chat/threads/{id}/messages stayed flat at about 50 ms per turn, from turn 1 to turn 150 (with the mock). GET /api/app/chat/threads/{id}/messages returns the whole thread, 221 KB for 300 messages, in 17 ms. The client refetches it at every turn start and settle.
Root cause. This comes from sourcemap-resolved CPU profiles and two diagnostic builds.
- Nothing is windowed.
MessageThread(app/features/chat/components/message-thread.tsx) maps every message to aMessageItem.- Rows get
[content-visibility:auto](message-item.tsx), which skips off-screen rows' layout and paint, but not their React render, markdown parse, syntax highlighting or i18n. - A cold open of the 300-message thread, profiled:
- React render ≈ 3.0 s inclusive;
- Shiki
codeToHtml≈ 0.66 s for the thread's ~40 code blocks (packages/ui/src/markdown/shiki.ts), though the thread opens scrolled to its last reply; - react-markdown/unified ≈ 0.42 s self;
- i18next/react-i18next ≈ 0.41 s self;
- GC ≈ 0.77 s.
PERF-B1intests/manual/suites/performance.mdsays older messages are recycled. They are not: 302 messages give 14,526 elements, about 48 per message.
- Every assistant row's toolbar re-renders when a turn starts.
- A diagnostic build (
diagnostic-d2.diff) counted, for one send in a 332-message thread:- 12
MessageItemrenders, so the row memo holds; - 167
MessageToolbarrenders, one per assistant row; - no toast dispatch.
- 12
- A profile of the 0.5–0.9 s task shows row chrome:
MessageToolbar,Button/cn/tailwind-merge,DropdownMenu,SkeletonMaskand i18next. Markdown takes about 20 ms of it. - So a subscription below the row memo re-renders every toolbar as a turn starts. It isn't pinned to one hook yet.
useToastis ruled out (no dispatch), and the row memo props are ruled out (no miss).
- A diagnostic build (
- Every row renders twice on open.
- The same diagnostic counted 664
MessageItemrenders for 332 rows, and the memo sawspeakAvailablechange on all of them. chat-surface.tsxderivesspeakAvailablefrom voice capabilities, the veto andviewerIsOwner, which settle after the first render.- Experiment S below removes this second pass and showed no measurable gain, so it is secondary.
- The same diagnostic counted 664
Experiments. These are evidence, not proposed patches; the diffs are in the TALE-361 task box.
- W:
MessageThreadrenders only the last 50 rows (candidate-w.diff). This is an upper bound for windowing, not an implementation: older rows become unreachable. - S:
MessageItem's memo ignoresspeakAvailable(candidate-s.diff).
Run 1, B W S S W B blocks: n=6 for open and switch, n=4 for send. The thread grew from 338 to 358 messages over the blocks, because each send adds two.
| Flow | main | W | S |
|---|---|---|---|
| Cold open | 5,013 ms (4,795–5,956) | 3,182 ms (2,884–3,399) | 5,566 ms (5,035–15,382)† |
| …longest task | 2,376 ms | 811 ms | 2,536 ms |
| …JS heap / elements | 111 MB / 18,416 | 56 MB / 4,932 | 104 MB / 18,841 |
| Switch into it | 2,952 ms (2,721–3,577) | 1,152 ms (1,070–1,332) | 3,166 ms (2,934–3,510) |
| …longest task | 2,529 ms | 778 ms | 2,692 ms |
| Send → first word | 1,138 ms (893–1,254) | (not valid‡) | 1,117 ms (1,010–1,167) |
†S's cold-open blocks ran under heavy external load (other tenants averaged 1.22 CPU, p90 2.17), so that cell is inconclusive. S's switch and send cells ran under normal load and show no gain either.
‡A harness predicate was satisfied by an earlier reply in the 50-row window. Run 2 detects the new reply row by its key.
Run 2 (3 Oct 11:15 occurrence, round r8). This replication ran on a fresh stack the occurrence owned, alternating B W W B, with n=6 for open and switch and n=4 for send. The thread grew from 300 to 316 messages. Other tenants averaged 0.34–0.37 CPU (p90 ≤ 0.58), and steal was 0.01.
| Flow | Short thread (same run) | main, 300-message thread | W, 300-message thread |
|---|---|---|---|
| Cold open | 1,946 ms (1,832–2,243) | 3,668 ms (3,459–4,151) | 2,484 ms (2,296–2,795) |
| …longest task | 346 ms | 1,556 ms (1,426–1,801) | 620 ms (551–694) |
| …JS heap / elements | 34 MB / 561 | 85 MB / 14,692 | 73 MB / 2,822 |
| Switch into it | — | 2,080 ms (1,953–2,224) | 762 ms (644–900) |
| …longest task | — | 1,700 ms (1,519–1,830) | 632 ms (561–661) |
| Send → first word | 520 ms (407–565) | 768 ms (694–833) | 519 ms (409–639) |
| …longest task between send and first word | 30 ms | 518 ms (472–596) | 84 ms (69–108) |
The send freeze shrinks with the number of rendered rows (518 ms → 84 ms with 50 rows), which is consistent with cause 2.
Limits
- The host is a VM cgroup capped at 2 CPUs and 4 GiB, and the browser is headless on localhost, so absolute times undercount a real network and differ on other hardware.
- Contention is recorded per sample window in the task's evidence bundle.
- Neither experiment ran the test suites.
- The idle server-side polling of
/stream(STREAM_POLL_MS= 250) was read from code, not measured.
Steps to reproduce
- Build: main
8b916c0b9or later.bun install --frozen-lockfile, thenbun run buildinservices/platform. - Stack (mode A,
tests/manual/setup.md):- the repo's mock gateway:
bun lib/mocks/start.ts; - the backend with
ROLE=all,TALE_PROVIDER_KEY_E2E_MOCK,TALE_ALLOW_PRIVATE_PROVIDER_HOSTS=1andTALE_CONFIG_BUILTIN_DIRset to a copy oftests/e2e/fixtures/config/default; vite previewofdist/.
- the repo's mock gateway:
- Organization:
- Sign up and create an organization.
- Copy
providers/e2e-mock.ymlinto$TALE_CONFIG_DIR/<slug>/providers/once theorg.scaffoldjob has run. - Add an environment-variable credential for it (Settings → AI providers, variable suffix
E2E_MOCK).
- Long thread:
POST /api/app/chat/threads, then 150 sequentialPOST …/threads/{id}/messages.- The replies need to be realistic markdown. The kit's
perf-mock.mjsstreams one perperf:md-<i>prompt.
- Measure: open the thread's URL in a fresh signed-in browser context, then switch to it from the Home panel, then send a message.
The kit, raw JSONL, CPU profiles, diagnostic counters and host monitor are in TALE-361's deliverable tale-361-perf-evidence-bundle.tar.gz, under occ-20261003T0315/ and occ-20261003T1115/:
seed-chat.mjs,perf-mock.mjs,setup-provider.mjs;chat-bench.mjs, with flowsthread-cold,switch,streamandtype;ab-chat.shandab-r8.sh;probe-memo.mjs,profile-analyze.mjs,summarize-chat.py,contention2.py.
Expected behavior
A long thread opens, switches and sends without freezing the page. Its cost per message stays bounded, as PERF-B1 promises. The acceptance budget below applies on this harness and host class, checked ABBA against the fix's base, n ≥ 6 per arm, with contention recorded:
- Cold open of the 300-message thread: median within +0.6 s of a short thread's median in the same environment, and a longest task ≤ 700 ms (median over samples).
- Run 2: +1.72 s with a 1,556 ms task. W: +0.54 s with 620 ms.
- Switch into it from the Home panel: median ≤ 1.0 s, with a longest task ≤ 700 ms.
- Run 2: 2,080 ms with a 1,700 ms task. W: 762 ms with 632 ms.
- Send in it: the first word paints within +150 ms of a short thread's, and the longest task between send and first word is ≤ 150 ms.
- Run 2: +248 ms with a 518 ms task. W: about +0 ms with 84 ms.
- DOM: ≤ 6,000 elements with the 300-message thread open (now 14,692; W 2,822). Otherwise
PERF-B1must say what the app really guarantees. The JS heap is reported, not budgeted: it mostly follows the cached thread data. - Kept:
- older messages stay reachable by scrolling, keyboard and screen reader, in the
role="log"history; - loaded messages stay findable with find-in-page;
- no scroll jump when older rows render;
- streaming has no task over 100 ms during a 600-word reply;
- typing has no key event over 50 ms.
- older messages stay reachable by scrolling, keyboard and screen reader, in the
Related:
- perf: Chat page scrolling jitter on devices without dedicated GPU #162 (closed): chat scrolling jitter.
- Bug: a 2,000-task board blocks the tab for 16–26 s when it is searched, left or opened #4062: per-card mount cost on large task boards. It's the same pattern: per-item chrome multiplied by an unwindowed list.
Affected service
Platform
Version or commit
main 8b916c0b9375ebe8c5f8043ddcf46f8c62e0b16c (3 Oct 2026). There are no chat-path changes through 1cd6cffba. The experiments are this commit plus candidate-w.diff, candidate-s.diff or diagnostic-d2.diff, none of them pushed.
Browser and OS
- Chromium 141.0.7390.37, headless, 1440×900, DPR 1, service workers blocked (Playwright-core 1.58).
- Linux 7.0, a 4 vCPU VM in a cgroup of 2 CPUs and 4 GiB.
- Node 24.21.0, bun 1.4.2, PostgreSQL 16.14 + pgvector 0.8.6.
Relevant log output
From the diagnostic build (probe-memo2.json), with a 332-message thread:
open: MessageItem renders 664 for 332 rows · memo misses {speakAvailable: 332} · MessageToolbar renders 498 · toast dispatches 0
typing: MessageItem renders 0 · MessageToolbar renders 0
one turn: MessageItem renders 12 · memo misses {region: 2, rootRef: 1, isLast: 1, message: 8} · MessageToolbar renders 167 · toast dispatches 0
Before submitting
- I searched existing issues and this hasn't been reported yet. I searched for long thread, chat performance, virtualize,
PERF-B1, message list, thread switch,content-visibility, Shiki, chat freeze and send message slow. No open issue covers the chat transcript's cost per message.
Activity
fix(platform): keep one clock value while the offset is learned
fix(platform): mount a long chat's older messages dormant
docs(manual): state what PERF-B1 guarantees for a large thread
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
tale-code-bot commentedon Nov 1, 2026
Landed on Tale's feature line: feature train #5241 landed on
release/0.6by rebase at 2026-11-01T01:56:42Z, and this change is now commit d64c135 there (perf(ui): stop copy buttons re-rendering on every toast). It ships with Tale 0.6.0.GitHub closes issues by itself only for commits on
main, so the feature-train role closes this one as completed. Task: TALE-62.perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
2 remaining items
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast
perf(ui): stop copy buttons re-rendering on every toast