Repository navigation
Stop repeated row walks while chat text streams - #49422
Conversation
- Hidden viewers keep held rows keyed once instead of rebuilding them on every push (STA-18484) - A streaming thought inside a work run records its position, so the run doesn't rescan its members (STA-18485) - A fresh transcript base no longer compares its rows with themselves (STA-18487) - A snapshot builds its row-ID set only if a live sink asks for it (STA-18488)
4550b52 to
26b5628
Compare
Perf scan: PR #49422 at 26b5628Verdict: PASS. No blocking perf findings. Graded on the head source ( What the diff adds or changes
Subscriptions and publications: the diff adds no subscription, listener, emit site or publication. The coalescer's Regression classes touched
Six questions
Evidence
Notes (non-blocking)
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Review status for 26b56285 Problem: four chat streaming paths walked a whole list again for each small update: a hidden chat holding streamed batches, a thought streaming inside a work run, a new transcript base, and a snapshot of a session with no live stream. Change for users: nothing visible. A chat that streams while hidden, or that has long work runs, does far less work per update. For example, 10,240 held batches dropped from 1,969 ms to 7.7 ms. Verified:
Deferred, non-blocking:
|
…#49422) - Hidden viewers keep held rows keyed once instead of rebuilding them on every push (STA-18484) - A streaming thought inside a work run records its position, so the run doesn't rescan its members (STA-18485) - A fresh transcript base no longer compares its rows with themselves (STA-18487) - A snapshot builds its row-ID set only if a live sink asks for it (STA-18488) (cherry picked from commit 5ae7183)
ELI5
While a chat streams, a few places were walking the whole list of rows again for every small update, even when only one row had changed. This PR makes those places touch only the row that changed. What you see in the chat stays the same.
What Changed
indexOf. The patched run also records which positions changed since the run was laid out, so the run's reader takes the direct path instead of walking every member. Before, the reader missed that path on every window.Why
These are mechanical fixes. Each keeps the existing data flow and output and removes the repeated full walk. No comparable: mechanical.
Linked Issue
Fixes STA-18484, STA-18485, STA-18487, STA-18488. STA-18486 was looked at and isn't fixed here: the fix needs a new viewer-interest field on the wire (see the ticket comment).
Visual Proof
N/A: no visual or interaction change. Only the internal work per update changed.
Testing
Bench on the exact paths: a throwaway vitest bench run on Linux, first on main and then with this change. The four changed files have no diff between the bench base and this head.
Existing tests pass: streamed-slots performance, work-run performance, coalescer held-text, and subscriber live-text/live-growth (29 tests).
The streamed-slots perf contract now asserts that the run records the streamed member's position. It fails without the fix.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
This removes work and adds none. Per held batch the cost goes from O(held rows) to O(rows in that batch). Per streamed window in a work run it goes from three passes over the run to one copy. The new-base self-compare and the inactive-snapshot ID set are skipped entirely.
Risk
The riskiest part is the held-batch merge: if the order or revision rules were wrong, a chat shown again after being hidden could draw an older row revision. The maps keep the same insertion order and the same rule that an older revision never wins, and header fields merge exactly as before. Phones and older hosts see no wire change. Backing out is a plain revert.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)