perf(server): skip full thread loads on projection and ingestion - #230
Merged
Conversation
Thread shell refresh, snapshots, and provider reactors were decoding every message, plan, and activity payload to compute a few summary fields. That cost grew with tool output size. Use SQL aggregates and keyed lookups instead. Client snapshots load activity payloads in 25-row batches. Metadata commands read the thread shell. Turn start reads one message. Runtime ingestion uses a joined thread context plus message, plan, and task-activity lookups. Live activity appends stay O(1) when already sorted. Cursor upsertMany is available; runtime projectEvent still commits per projector so attachment cleanup stays after each projector transaction. Adapted from pingdotgg/t3code pingdotgg#9000 pingdotgg#8988 pingdotgg#9152 pingdotgg#9662 pingdotgg#9671 pingdotgg#9706 pingdotgg#9758 pingdotgg#10108 pingdotgg#10120 pingdotgg#10341.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR replaces full thread-history decoding in projection and provider-ingestion paths with bounded, purpose-specific persistence queries while preserving client snapshot and runtime behavior.
Confidence Score: 5/5Safe to merge; no outstanding blocking issues remain. The prior activity-identifier finding was resolved by greptile-apps[bot] without explanation. The current code passes the repository's full projected activity shape to the task-title helper, which only requires its kind and payload fields. Reviews (4): Last reviewed commit: "Merge branch 'main' into perf/narrow-pro..." | Re-trigger Greptile |
5 tasks
Controller helpers still required a full OrchestrationThread after the shell lookup, and task-title fallback passed projection activity records into a helper typed on activity.id. Narrow those signatures to the fields they actually read. Grok 4.6 High via Grok Build.
Greptile reproduced TS2739/TS2345: turn-start helpers still required a full OrchestrationThread after the shell lookup, and task-title fallback passed projection activityId records into a helper typed on activity.id. The helpers now take the Akeru ownership and payload fields they actually read. Grok 4.6 High via Grok Build.
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
Thread shell refresh, client snapshots, and provider reactors decoded every persisted message, plan, and activity payload to compute a few summary fields. Large tool outputs made those reads cost more memory than the result required.
Adaptation
Ported the remaining narrow projection and ingestion lookups from T3 Code, keeping Akeru bot, group, channel, author, reaction, and delegation fields.
id,botId,groupId,respondingBotId,interactionMode) instead of a fullOrchestrationThread.kindandpayload, so records keyed byactivityIdcompile.thread.activity-appendedstays O(1) when the current array was produced by the reducer and is already sorted.upsertManyexists for projector cursors. RuntimeprojectEventstill commits each projector separately because attachment cleanup runs after each projector transaction. Combining those commits is shared with checkpoint attachment-transaction work and is not in this PR.Upstream
Adapted from pingdotgg/t3code:
Scope
This PR is projection and ingestion query narrowing only. Logging (pingdotgg#8187 remaining) is #240. Incremental transcript scans (pingdotgg#9024) are still separate. Checkpoint attachment cleanup after outer command commit is owned by the checkpoint-safety work.
Verification
Focused tests:
activityIdtitle lookuperror TSonakeru-botafter the repairIsolated browser on
a354e64f2, home/tmp/akeru-ui.cGmS1M, web 6836 / server 14876:Projection check(Scout boss, Relay specialist) rendered from the roster; a live send showedScout is working, then a completed Scout error reply/bots/ui-scoutrestored Scout history plus the reaction; opening the group from the roster restored group history/groups/...before the roster store is populated still crashesGroupThreadLanding(useReplyPlaybackThreadafterif (!group) return null). That hook-order bug is pre-existing and not introduced hereImplemented and verified by Grok 4.6 High in Grok Build via Orca.