Skip to content

agent: Make messages vec cheap to clone #57712

Merged
Veykril merged 1 commit into
mainfrom
push-usqpmrztnuzz
May 26, 2026
Merged

agent: Make messages vec cheap to clone #57712
Veykril merged 1 commit into
mainfrom
push-usqpmrztnuzz

Conversation

@Veykril

@Veykril Veykril commented May 26, 2026

Copy link
Copy Markdown
Member

For long threads we will spend more and more time cloning the messages just to save them to the database, as we need a copy of everything to do so asynchronously. Messages are really expensive to clone though and we accumulate a lot of them really fast, so even for smaller threads we start seeing pauses in the millisecond range. The fix to this is fairly simple though, we never mutate the messages once pushed to the vec, so just Arc them.

This PR also slightly changes UserMessage to be a bit faster to clone as well.

Release Notes:

  • Fixed a cause of stutters when interacting with the agent

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 26, 2026
@Veykril Veykril requested review from benbrandt and bennetbo and removed request for bennetbo May 26, 2026 09:47
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 26, 2026
For long threads we will spend more and more time cloning the messages just to save them to the database, as we need a copy of everything to do so asynchronously.
Messages are really expensive to clone though and we accumulate a lot of them really fast, so even for smaller threads we start seeing pauses in the millisecond range.
The fix to this is fairly simple though, we never mutate the messages once pushed to the vec, so just Arc them.

This PR also slightly changes `UserMessage` to be a bit faster to clone as well.
@Veykril Veykril force-pushed the push-usqpmrztnuzz branch from 0e02c42 to 61c8b40 Compare May 26, 2026 09:50
@Veykril

Veykril commented May 26, 2026

Copy link
Copy Markdown
Member Author

/cherry-pick preview

@Veykril Veykril enabled auto-merge May 26, 2026 09:54
@Veykril Veykril added this pull request to the merge queue May 26, 2026
Merged via the queue into main with commit 63ff997 May 26, 2026
32 checks passed
@Veykril Veykril deleted the push-usqpmrztnuzz branch May 26, 2026 10:03
@zed-zippy

zed-zippy Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

🍒💥 Cherry-pick did not succeed
https://github.com/zed-industries/zed/actions/runs/26445755481

TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 2, 2026
For long threads we will spend more and more time cloning the messages
just to save them to the database, as we need a copy of everything to do
so asynchronously. Messages are really expensive to clone though and we
accumulate a lot of them really fast, so even for smaller threads we
start seeing pauses in the millisecond range. The fix to this is fairly
simple though, we never mutate the messages once pushed to the vec, so
just Arc them.

This PR also slightly changes `UserMessage` to be a bit faster to clone
as well.

Release Notes:

- Fixed a cause of stutters when interacting with the agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants