Repository navigation
perf: reduce event replay and projection CPU usage - #16
Merged
Merged
Conversation
…audit Addresses the audit's findings with minimal, desktop-first changes (no payload deferral, no streaming-path work since streaming is off by default): - Sidebar: replace the 10-thread bulk detail prewarm with a single hover-based prewarm; at idle one shell stream + at most one detail stream - Server replay: thread catch-up reads only the thread's aggregate stream via the (aggregate_kind, stream_id, sequence) index instead of scanning the global log; shell catch-up is bounded (500 events) with a shell snapshot fallback for stale cursors - Shell summaries: thread.message-sent updates latestUserMessageAt incrementally; activity-appended triggers the history-wide summary rebuild only for approval/user-input activity kinds; streaming assistant chunks no longer fan out per-chunk shell upserts - Client runtime: O(1) activity appends when order is preserved; skip IndexedDB full-snapshot encodes while a turn is running (settle event and scope finalizer persist the final state) - Timeline derivation: share one ordered activities view across the four derivations (identity-cached, O(n) sorted check); k-way merge for the combined timeline instead of concat+sort - Composer drafts: debounce JSON serialization itself, and cache per-draft partialization by object identity so typing doesn't re-clone every retained draft - Shiki: negative-cache languages without grammars (sh, yaml) so those fences stop retrying and throwing on every render - Bootstrap polling: one shared change-detecting poller instead of one 2s interval per consumer; minimap only writes data-in-view on change Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The composer store was its only production consumer; port its tests to createDebouncedJsonStorage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ity fan-out - Sidebar hover prewarm: match Element instead of HTMLElement so resting on a row's SVG icons (status pill, PR badge) still resolves to the row's prewarm key instead of cancelling the hover. - Shiki negative cache: bound it (100 entries) since fence labels are arbitrary text; evict failed loads from the promise cache so transient failures stay retryable; stop adding render-time codeToHtml throws to the negative cache so one pathological block can't disable highlighting for a supported language. - Activity projection: skip the thread-row upsert entirely for non-summary activity kinds (not just the history rebuild) and skip the corresponding shell re-broadcast in ws.ts — high-volume command/output/progress streams no longer churn updatedAt or fan out per-event shell upserts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
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.
Large installations can spend sustained CPU decoding unrelated event history, rebuilding full projection summaries, and repeating client-side work during active streams. This is an adapted port of upstream PR pingdotgg#3825 against the current orchestration and runtime-heartbeat contracts.
The change adds aggregate-indexed replay, incremental projection updates, bounded per-thread catch-up with snapshot fallback, and targeted client hot-path reductions. It preserves current last-agent-activity reporting and omits older optimizations already superseded by main.
Implemented with GPT-5.6 Codex.