Repository navigation
perf(inbox): read message bodies only for pages that include them - #126
Merged
Merged
Conversation
fetch_inbox and the session inbox selected body_md for every row and then dropped it unless include_bodies was set. With include_bodies off they now select NULL instead. fetch_inbox p50 for 20 messages: 57 to 48 us at 2 KB bodies, 82 to 52 us at 17 KB.
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.
fetch_inboxandfetch_session_inboxselectedbody_mdfor every row of the page and then dropped it unlessinclude_bodieswas set, which is off by default. With it off they now selectNULL AS body_md, so SQLite no longer reads the body from the message row.fetch_inboxfor a page of 20 messages, in process, p50 of 10,000 calls on this machine:Output is unchanged: the response builders only read
body_mdwheninclude_bodiesis set, and existing tests cover both cases.bun run checkand the full suite (1214 pass, 0 fail) pass.I did not change the other cost found in the same profile, the
UPDATE agents SET last_active_tsthat every successful agent call performs. That write is documented behavior (it orderslist_agents, shows inwho, and un-retires an idle agent), so removing it fromfetch_inboxwould make a polling agent look idle. It is about 13% of afetch_inboxrequest and left as is.Summary by CodeRabbit