Repository navigation
Conversation
… an open channel Every peer message re-rendered the whole timeline, so the cost of one message grew linearly with the rows already open (about 3 us per row per message). - Virtualizer builds row elements lazily for the visible range instead of mapping every row on each render. - Latest/catch-up ids come from the newest row instead of scanning the list. - Cache sort keys, relayed-from claims, thread references and thread roots per immutable event/row object so they are computed once. - Skip membership and activity presentation work when no membership or agent rows are present. - Reconcile and window merging in the relay store make a single pass and skip prune loops that cannot match. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Joah Gerstenberg <joah@squareup.com>
This branch has not been deployed
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.
Problem
Every incoming message in an open channel did work proportional to the number of rows already open: the timeline mapped every row into an element on each render, scanned the list for the latest and catch-up ids, and the relay store re-derived sort keys, relayed-from claims, thread references and thread roots for every row. At about 2,300 open rows that was roughly 3 us per row per message at 1x, and it grows with channel length.
Fix
ChannelTimelinehands rows to the Virtualizer asdatawith a function child, so elements are only built for the visible range. The latest/catch-up ids come from a newnewestRowhelper, the id lookup is lazy, and the kept-rows and target-index guards avoid rebuilding when nothing changed.eventMsinmessage-order, relayed-from claims,thread-reference, thread roots inTypingIndicator.rowsProfileKeyreplaces repeated per-row profile key construction inuseRowProfiles.membershipRowswith no membership rows,activity-presentationwith no agent rows (lazy neighbor lookup and lazykeep).reconcileandsetWindowmake a single pass, and the prune and trim loops exit early when they cannot match.No freezing changes; arrays are not frozen or sealed in any hot path.
Results
Per peer message, live window minus quiet window, 60 messages at 4 per second, mean of per-round medians over interleaved A/B rounds (order alternated each round), host load1 6-10 during the runs. Base is origin/main at the same commit.
Script time per message no longer grows with row count on the branch (5.0 to 5.9 ms from 300 to 2,300 rows at 1x, against 5.0 to 8.8 ms before). Timeline inclusive CPU-profile slope went from 1.44 to about 0.33 us per row per message.
Known costs and limits:
Tests
newestRow), message projection reconcile, and activity presentation including thread-root freshness. Each cache guard was mutated once and a test failed for each; one mutant (memory-only owners prune in reconcile) is equivalent and cannot be killed.tsc --noEmitpass; biome on the changed files is clean.--no-deps: 98 failures on the branch and 101 on origin/main on this host, and the branch failures are a subset of the base failures.scroll.spec.mjsfails the same 4 cases on both.🤖 Generated with Claude Code