Batch history store appends into one update per tick - #108
Merged
Conversation
outputStore and channelHistoryStore rebuilt their entire capped backing array on every message: each append spread the existing entries into a new array and sliced it, costing two allocations of up to 500/1000 elements per line, paid precisely when the client is busiest. Appends within a tick are now queued with ids assigned at enqueue time and flushed by a single queueMicrotask set(): one concat, sliced only when actually over the cap, and one store notification per burst instead of one of each per message. output.tsx already consumes entries incrementally by id and handles multiple entries per notification, so consumers are unchanged. reset() discards pending entries synchronously; an already-queued flush then no-ops. Tests that asserted store contents synchronously now await the microtask flush. Fixes #102 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 12, 2026
Batch history store appends into one update per tick 49e6b1d
6 tasks
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.
Fixes #102
outputStoreandchannelHistoryStorepreviously rebuilt and sliced their capped backing arrays for every message, paying O(n) allocation and subscriber work at the busiest times.Changes
Output's existing imperative id-based consumption; switchuseChannelHistoryto the direct Zustand subscription so React cannot coalesce away the full-burst delivery notification.reset()semantics by discarding pending entries and resetting counters; an already-queued flush then no-ops.TDD and verification
tsc --noEmitand the production Vite build pass.