Repository navigation
perf(threads): read to the unread frontier in one thread load - #3822
Draft
kalvinnchau wants to merge 3 commits into
Draft
kalvinnchau wants to merge 3 commits into
kalvinnchau wants to merge 3 commits into
Conversation
opening a thread with unread replies paged older one load per positioning decision, and every load re-read the thread root first. loadMore now takes the read frontier and pages until it reaches a reply at or before it, so the root is validated once per open instead of once per page. adds thread-unread-open-60/200 perf cases. the production-broker fixture now honors olderPageDelayMs instead of holding older pages until a test releases them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
a load to the read frontier now asks for up to four pages per thread_window request, the relay's 200-row maximum, and counts each window as the pages it covers. the load range stays ten pages of 50 rows, so a long thread still stops at the same 460 replies, in fewer serial round trips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
thread panel now asks the unread store for a thread's read-through time; give the remaining session fakes that mount it a stub. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kalvin Chau <kalvin@block.xyz>
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
When a thread with unread replies opens, the reader pages older until it reaches the first unread reply, and it keeps the thread hidden until then. Each older page was a separate
loadMore()started by the panel's positioning decision. Each of those loads first re-read the thread root, so a 200-reply unread thread made four serial root reads and four serial 50-row window reads before showing anything.Change
ThreadView.loadMore(through?)pages within one load until it reaches a reply at or beforethrough. The root is validated once per load, as a retained-range repair already does.ThreadPanelpasses the read frontier it already compares against.thread_windowrequest. That is 200 rows, the relay'sthread_windowmaximum (MAX_LIMITin block/buzzcrates/buzz-core/src/thread_window.rs). Each window counts as the pages it covers, so the load range stays at ten 50-row pages and a long thread still stops at 460 replies.thread-unread-open-60andthread-unread-open-200open a strict-window thread whose replies are all unread.olderPageDelayMs. The new cases need a modeled round trip, so the policy relay now releases held pages afterolderPageDelayMswhen it is set. Existing production-broker cases do not set it.Relay reads per unread open that needs R older replies: before, ⌈R/50⌉ root reads plus ⌈R/50⌉ window reads. Now, 1 root read plus ⌈R/200⌉ window reads. Rows read are unchanged.
Evidence
bin/pnpm perf --scenario thread-unread-open-{60,200} --repeat 3, Chromium, 150 ms modeled round trip, local machine. Main (46a09db) and this branch were run interleaved, two rounds each. Times are medianfirstRowsMs:--cpu 1--cpu 4--cpu 1--cpu 4The 60-reply case needs only one older window, so it is unchanged. At 4× CPU, most of the time that remains is spent mounting every hidden reply row before positioning. This change does not address that.
Validation
bin/pnpm checkbin/pnpm vitest run src/features/relay/thread-window.test.ts src/features/relay/threads.test.ts src/features/messages/ThreadPanel.test.tsx: 186 passed. New thread-window tests cover:limited, 460 replies.bin/pnpm test:browseron thread-unread, thread-window, thread-opening, inbox-tabs and inbox-live-read specs, Chromium and WebKit: 88 passed.Known limitation: if a frontier load fails partway, the rows it read stay in the view, but its cursor does not advance. Retry re-reads those pages.