Skip to content

perf(ai): guard update_imported_comments_disabled_state with conversation registry#13114

Open
acarl005 wants to merge 1 commit into
andy/long-convo-latency-block-focus-optimizationfrom
andy/long-convo-latency-imported-comments
Open

perf(ai): guard update_imported_comments_disabled_state with conversation registry#13114
acarl005 wants to merge 1 commit into
andy/long-convo-latency-block-focus-optimizationfrom
andy/long-convo-latency-imported-comments

Conversation

@acarl005

@acarl005 acarl005 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

Part of a stack of performance fixes for #9799.

This PR: update_imported_comments_disabled_state was triggered on every BlocklistAIHistoryEvent for every AI block. Internally it called is_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> to BlocklistAIHistoryModel, 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

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

Manually loaded a conversation with 3014 AI exchanges and confirmed reduced CPU during restore.

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

acarl005 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@oz-for-oss

oz-for-oss Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@acarl005

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 /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@acarl005 acarl005 force-pushed the andy/long-convo-latency-imported-comments branch from e64e970 to 9512de5 Compare June 26, 2026 23:49
@acarl005 acarl005 force-pushed the andy/long-convo-latency-block-focus-optimization branch 2 times, most recently from f9f0193 to e5d6e80 Compare June 27, 2026 00:15
@acarl005 acarl005 force-pushed the andy/long-convo-latency-imported-comments branch from 9512de5 to a513085 Compare June 27, 2026 00:15
@acarl005 acarl005 force-pushed the andy/long-convo-latency-block-focus-optimization branch from e5d6e80 to bcecab0 Compare June 27, 2026 01:21
@acarl005 acarl005 force-pushed the andy/long-convo-latency-imported-comments branch from a513085 to 62a1c1a Compare June 27, 2026 01:21
@acarl005 acarl005 force-pushed the andy/long-convo-latency-block-focus-optimization branch from bcecab0 to e0445ff Compare June 27, 2026 02:13
@acarl005 acarl005 force-pushed the andy/long-convo-latency-imported-comments branch from 62a1c1a to 7cb4072 Compare June 27, 2026 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant