Skip to content

perf(desktop): prefetch the channel window on sidebar hover intent - #6534

Open
Maxwellimus wants to merge 1 commit into
fix/switch-visual-stabilityfrom
perf/sidebar-hover-prefetch
Open

perf(desktop): prefetch the channel window on sidebar hover intent#6534
Maxwellimus wants to merge 1 commit into
fix/switch-visual-stabilityfrom
perf/sidebar-hover-prefetch

Conversation

@Maxwellimus

@Maxwellimus Maxwellimus commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Based on perf/switch-tracing — retarget to main after it merges. (Shares the message-window queryFn hunk with the tracing instrumentation.)

A deliberate hover on a sidebar channel row (100ms dwell — pointer scrubbing never fires) warms that channel's message window, so the subsequent click paints from cache instead of paying the relay fetch on the switch path. Live traces measured that fetch at 180–310ms per cold channel entry on a real community — this moves it into the hover dwell, ahead of the click.

The window's query options move into a shared factory so the prefetched entry is byte-identical to what the mounted query reads; the prefetch respects the window's staleTime (hovering a fresh channel never refetches) and dedupes with in-flight fetches. Forum channels are excluded, matching the window query's own gating.

The post-subscribe window refresh cancels an in-flight prefetch rather than deduping onto it: a prefetch reaches the relay before the live subscription exists, so its snapshot can miss events that landed in between. A cold mount fetch is still parked on the persisted-head gate, carries no such gap, and must keep deduping (#6455's one-fetch contract) — channelWindowPrefetches.ts is the marker that tells the two apart.

The mock bridge gains a head-fetch probe (cursorless window reads) and a regression spec asserts both directions: dwell fetches exactly once before any click; scrubbing across rows fetches nothing.


Recreates #6459. It was approved and squash-merged into its stacked base perf/switch-tracing, but a force-push of that base (carrying the review-requested P1 fixes for #6455) raced the merge and overwrote the squash commit — so the merged content never survived on the base branch. Same content, same base; still stacked on #6455 and should merge after it.

@Maxwellimus
Maxwellimus requested a review from a team as a code owner August 22, 2026 01:11
@Maxwellimus
Maxwellimus requested a review from wesbillman August 22, 2026 01:11
@Maxwellimus
Maxwellimus force-pushed the perf/sidebar-hover-prefetch branch from 6fce904 to 06051a3 Compare August 22, 2026 16:53
@Maxwellimus
Maxwellimus force-pushed the perf/sidebar-hover-prefetch branch from 06051a3 to d6aa876 Compare August 22, 2026 17:22
@Maxwellimus
Maxwellimus force-pushed the perf/switch-tracing branch 3 times, most recently from 3994382 to a0a7989 Compare August 26, 2026 19:37
@Maxwellimus
Maxwellimus force-pushed the perf/sidebar-hover-prefetch branch from d6aa876 to b90987f Compare August 26, 2026 19:55
A deliberate hover on a sidebar channel row (100ms dwell, so pointer
scrubbing never fires) warms that channel's message window, making the
subsequent click a cache hit instead of paying the relay fetch on the
switch path.

The window query options move into a shared factory so the prefetched
entry is byte-identical to what the mounted query reads; the prefetch
respects the window's staleTime, so hovering a fresh channel never
refetches. The mock bridge gains a head-fetch probe (cursorless window
reads) so the regression spec can assert dwell-fetches-once /
scrub-fetches-never.

Signed-off-by: Max Lampert <maxwell@squareup.com>
@Maxwellimus
Maxwellimus force-pushed the perf/sidebar-hover-prefetch branch from b90987f to a88994e Compare August 27, 2026 05:17
@Maxwellimus
Maxwellimus changed the base branch from perf/switch-tracing to fix/switch-visual-stability August 27, 2026 05:17
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