Repository navigation
fix(web): keep streaming updates independent of history length - #870
Merged
Merged
Conversation
Reuse persisted transcript signatures, skip unchanged live-tool snapshots, attribute turns in one pass, and bound thinking timings to the visible window plus the reading-window bridge. Co-authored-by: tt-a1i <[email protected]>
Co-authored-by: tt-a1i <[email protected]>
A live user without a timestamp must still match one timestamped native payload, and an append on the same entries array must rebuild the cached projection. Streaming updates that leave the array unchanged keep the cache hit. Co-authored-by: tt-a1i <[email protected]>
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
Fixes #837.
Streaming
message_updateevents rebuilt transcript signatures for the whole persisted history and copied an unbounded thinking-timing map on every update. Turn attribution also scanned from the start of the row list for each timing row. The cost grew with history bytes and with the number of timing keys retained in a long-lived session. This follows the audit in #841 and does not replace the unchanged-history Markdown memo from #434.Value
A live token no longer pays for history that did not change. Visible reasoning durations stay attached to the current live messages and to thinking entries still in the selected session, and completed timings that the snapshot has not adopted yet stay only up to the transcript reading window. A live user prompt that has no timestamp still collapses onto the one matching native prompt, and an entry appended to the same history array still appears.
Approach
reduceLiveToolsreturns the same array when a non-tool event or a settled turn does not change tool evidence, and the store skips the snapshot write in that case. Cursor order, recovery, and terminal state are unchanged.findIndexfrom the start of the rows for every timing row.message-${role}-${timestamp}) and by entry id. Completions not yet in that snapshot are kept in a pending list capped atWEB_MAX_ENTRIES * 4, the same reading window the transcript already uses. A later snapshot that still contains the entry keeps the duration; a window that no longer contains it drops the key.Validation
Same machine, Bun 1.3.14, the #837 synthetic repro. Before is one run at
78dc574. After wall-clock figures are medians of five runs. The regression gate is the counts, not the milliseconds. No test retries and no widened timeouts.thinkingStarts1000, 3000 notificationsthinkingStarts8,thinkingDurations0, 2000 notificationsbuildEntries× 100, 250 history messages (~0.53 MB)JSON.stringifycalls, ~103.8M charsJSON.stringifycalls, 9400 charsbuildEntries× 100, 1000 history messages (~2.13 MB)JSON.stringifycalls, ~415.4M charsJSON.stringifycalls, 9400 charsfindIndexcallsThe 200 stringify calls are two serializations of the live message per call. They do not grow from 250 entries to 1000. The turn-read ratio stays flat while the old search counts grow with the square of the turn count. The 0-key store time stays at 3.2 ms; that sample is not a speedup.
Browser evidence
Separate from the Bun counts. One headless Chrome run (system Chrome, 1280×800, Vite dev) of the real
Transcripton a synthetic page. Each history message is 1000xcharacters in bothcontentand a text part. Before is78dc574. After is this working tree. Each sample is 20 streamed updates, each in its own task, then 12 input events that each apply one more update and wait for the next frame. React ProfileractualDuration,PerformanceObserverlongtask, and input-to-frame time. A favicon 404 was the only page error. These samples did not get faster: a commit still rebuilds the history row tree, which dominates the signature work the Bun counts isolate.bun run checkpassed on this revision, including the committedweb/distbundle.bun run test uipassed locally after the reconciliation fix (99 files, 1529 tests). The added tests fail if a timestamp-free live copy of a timestamped prompt becomes a second row, or if a message pushed onto the same history array stays hidden. They do not use timers, retries, or wider timeouts.CI for
a47577c02897413dfa5eaa5f355ea7c159c6a34fcompleted with every check passing: https://github.com/openpi-dev/openpi/actions/runs/38914679573Impact