Repository navigation
perf(plugins): Read the newest History replacement with one query - #4231
Merged
Merged
Conversation
Prompt history found the newest compaction or handoff through the paged event query, which also checks for older matches in a second, sequential query that prompt history never reads. The event store now reads the newest event of the given types directly. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This comment has been minimized.
This comment has been minimized.
BYK
approved these changes
Nov 24, 2026
23 tasks done
This branch was successfully deployed
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.
loadHistoryfinds the newest compaction or handoff with the pagedeventStore.query({ limit: 1 }). When one exists, that method also runs ahasOldercheck as a second query, after the first query finishes. Prompt history never reads its result.About 20% of production
plugin.prompt_history.loadspans run this extra query. Their p50 is about 62 ms, against about 17 ms without it, so the unused query adds about 45 ms at p50.The event store gets
loadLatestEventOfTypes(conversationId, types): one query for the newest row of the given types.EXPLAINshows one index scan on(conversation_id, type, seq).startedAtMsand the returned contexts do not change, and the existing prompt-history scenario already covers a compaction.Related: #3784.
via @BYK.
--
View Session [Sentry]