[Archive] perf(message-scroller): transcript virtualization (A+B) — evaluated, deferred - #1318
Closed
roxi3906 wants to merge 4 commits into
Closed
[Archive] perf(message-scroller): transcript virtualization (A+B) — evaluated, deferred#1318roxi3906 wants to merge 4 commits into
roxi3906 wants to merge 4 commits into
Conversation
… @tanstack/react-virtual
…ent estimates Streaming into a long transcript rebuilt per-row data with O(n) scans of conversationGraph.messages (graph node lookup, revisions collection) for every row on every 33ms presentation tick — O(rows^2) per tick. At 2000 rows this produced multi-hundred-ms long tasks per streamed chunk (p95 frame 134-172ms, 16 longtasks/~1.9s per stream). Hoist the scans into per-render indexes memoized on conversationGraph identity (graphMessageNodeById, graphRuntimeSegmentById, revisionMessagesByRootId, messageCreatedAtById, subsequentTurnCountByMessageId), making the row map O(1) per row. Also let MessageScrollerItem take a containmentEstimate and pass per-row-type contain-intrinsic-size values (user 3rem, agent 21rem, from measured row heights), cutting scrollHeight drift while offscreen rows resolve from ~8.5% to ~1%. Benchmark (2000 rows, streaming): frame p95 134-172 -> 66-68ms, longtasks 16 -> 5, longtask total ~1.9s -> ~0.5s; scroll and TTI unchanged. Adapted to the virtualized transcriptRows descriptor builder on this branch: the memoized graph indexes (graphMessageNodeById, graphRuntimeSegmentById, revisionMessagesByRootId) and the message maps are consumed inside the row-builder memo instead of the old inline render map, so the per-row O(n) graph scans are gone from the descriptor rebuild as well. containmentEstimate coexists with virtualization (applies to mounted rows only).
Contributor
Author
|
Closing as archive-only: virtualization evaluated and deferred (see PR body for benchmark comparison and rationale). Branch retained on origin for reference. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Archived for reference — not intended for merge. Evaluation branch for transcript virtualization per the shadcn Message Scroller Virtualization recipe, combined with the indexing fix from #1210 (A+B).
Contents
ac2664f0— virtualize transcript rows past a 100-row threshold with@tanstack/react-virtual@3.14.9; app-side anchoring/follow-output engine replaces the primitive's MutationObserver-based behavior on the virtualized path.c07a45b1— cherry-pick of the per-row graph-lookup indexing fix from perf(message-scroller): transcript perf fixes + keep identity continuous across session bind #1210, adapted to consume the memoized indexes inside the virtualizedtranscriptRowsdescriptor builder.Benchmark (2000 messages, same protocol as #1210)
Why deferred
content-visibilityalready covers the 500–2000 row range; virtualization's streaming win only completes when combined with A.scrollToMessagereturns false for unmounted rows, and find-in-page / cross-range selection / accessibility tree cover only mounted rows.Verification (final combined build)
Perf spec 2 passed; message-scroll anchor/reanchor/release e2e 3 passed; 189 related unit tests pass unmodified; tsc (web+node) and eslint clean (one informational
react-hooks/incompatible-librarywarning foruseVirtualizer).