perf(ai): guard update_imported_comments_disabled_state with conversation registry#13114
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
I'm starting a first review of this pull request. You can follow along in the session on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR adds a conversation-level imported-comments registry and uses it to avoid updating the Open all imported comments disabled state for conversations that have never received imported comments.
Concerns
- No blocking concerns found.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
e64e970 to
9512de5
Compare
f9f0193 to
e5d6e80
Compare
9512de5 to
a513085
Compare
e5d6e80 to
bcecab0
Compare
a513085 to
62a1c1a
Compare
bcecab0 to
e0445ff
Compare
62a1c1a to
7cb4072
Compare

Description
Part of a stack of performance fixes for #9799.
This PR:
update_imported_comments_disabled_statewas triggered on everyBlocklistAIHistoryEventfor every AI block. Internally it calledis_latest_visible_exchange_in_root_task, which scanned all exchanges of the conversation to find the latest visible one — O(n) per event. For a 3000-exchange conversation with frequent events, this added up significantly during restore.Adds
conversations_with_imported_comments: HashSet<AIConversationId>toBlocklistAIHistoryModel, maintained as conversations import/clear comments. The expensive check is now skipped entirely with an O(1) set lookup for the vast majority of conversations that have no imported comments.Linked Issue
Fixes #9799
ready-to-specorready-to-implement.Testing
Manually loaded a conversation with 3014 AI exchanges and confirmed reduced CPU during restore.
./script/runAgent Mode