Skip to content

Fix some overcomputation in the project diff - #57859

Merged
cole-miller merged 5 commits into
mainfrom
improve-conflicts-performance
Jun 4, 2026
Merged

Fix some overcomputation in the project diff#57859
cole-miller merged 5 commits into
mainfrom
improve-conflicts-performance

Conversation

@cole-miller

@cole-miller cole-miller commented May 27, 2026

Copy link
Copy Markdown
Member
  • Don't emit unnecessary edited events from the multibuffer when setting excerpts is a no-op
  • Limit excerpt recomputation in the project diff when diffs or conflicts change to just the affected buffer
  • Ignore diff events in the project diff that can't affect excerpt boundaries

Also includes some drive-by improvements to the handling of merge conflicts:

  • Await initial conflicts parse when opening a conflict set (like diffs), so we don't see an initial incorrect "no conflicts" state
  • Make the project diff subscribe to conflicts directly instead of indirecting through the editor (also like diffs)
  • Instead of saving the affected buffer when resolving a conflict, just avoid re-registering dirty buffers with the project diff, so that excerpts for conflicts don't disappear quite so eagerly (once more: like diffs)

The combination of these changes greatly cuts down the amount of time spent syncing the DisplayMap, which is especially bad for the split view.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Improved the performance of the project diff, especially in the presence of merge conflicts
  • Fixed conflicts disappearing too quickly from the project diff when editing
  • Fixed conflicts sometimes taking a while to appear in the project diff during large merges

- don't emit unnecessary edited events from the multibuffer
- await initial conflicts parse when opening a conflict set for the first time
- make the project diff subscribe to conflicts directly instead of indirecting through the editor
- limit excerpt recomputation in the project diff when diffs or conflicts change
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 27, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 27, 2026
@cole-miller
cole-miller force-pushed the improve-conflicts-performance branch from ca68c12 to 3f81cbe Compare June 4, 2026 18:15
@cole-miller
cole-miller enabled auto-merge June 4, 2026 21:46
@cole-miller
cole-miller added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit 8612c62 Jun 4, 2026
34 checks passed
@cole-miller
cole-miller deleted the improve-conflicts-performance branch June 4, 2026 21:57
@zed-zippy zed-zippy Bot added the PR state:needs review Used to label PRs that are in need of a post-merge approval label Jun 4, 2026
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 8, 2026
- Don't emit unnecessary edited events from the multibuffer when setting
excerpts is a no-op
- Limit excerpt recomputation in the project diff when diffs or
conflicts change to just the affected buffer
- Ignore diff events in the project diff that can't affect excerpt
boundaries

Also includes some drive-by improvements to the handling of merge
conflicts:
- Await initial conflicts parse when opening a conflict set (like
diffs), so we don't see an initial incorrect "no conflicts" state
- Make the project diff subscribe to conflicts directly instead of
indirecting through the editor (also like diffs)
- Instead of saving the affected buffer when resolving a conflict, just
avoid re-registering dirty buffers with the project diff, so that
excerpts for conflicts don't disappear quite so eagerly (once more: like
diffs)

The combination of these changes greatly cuts down the amount of time
spent syncing the `DisplayMap`, which is especially bad for the split
view.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved the performance of the project diff, especially in the
presence of merge conflicts
- Fixed conflicts disappearing too quickly from the project diff when
editing
- Fixed conflicts sometimes taking a while to appear in the project diff
during large merges
for buffer in buffers {
open_conflict_set_for_buffer(editor, buffer, cx);
}
}

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.

Would there even be more than one buffer if it's a singleton buffer? Seems like it would be simpler to do something like buffer.read(cx).as_singleton...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, forgot to clean this up when I changed conflict handling for multibuffers, thanks!

@Anthony-Eid

Anthony-Eid commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@zed-zippy approve

@Anthony-Eid

Anthony-Eid commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@zed-industries/approved

@zed-zippy zed-zippy Bot removed the PR state:needs review Used to label PRs that are in need of a post-merge approval label Jun 9, 2026
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
- Don't emit unnecessary edited events from the multibuffer when setting
excerpts is a no-op
- Limit excerpt recomputation in the project diff when diffs or
conflicts change to just the affected buffer
- Ignore diff events in the project diff that can't affect excerpt
boundaries

Also includes some drive-by improvements to the handling of merge
conflicts:
- Await initial conflicts parse when opening a conflict set (like
diffs), so we don't see an initial incorrect "no conflicts" state
- Make the project diff subscribe to conflicts directly instead of
indirecting through the editor (also like diffs)
- Instead of saving the affected buffer when resolving a conflict, just
avoid re-registering dirty buffers with the project diff, so that
excerpts for conflicts don't disappear quite so eagerly (once more: like
diffs)

The combination of these changes greatly cuts down the amount of time
spent syncing the `DisplayMap`, which is especially bad for the split
view.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved the performance of the project diff, especially in the
presence of merge conflicts
- Fixed conflicts disappearing too quickly from the project diff when
editing
- Fixed conflicts sometimes taking a while to appear in the project diff
during large merges
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
- Don't emit unnecessary edited events from the multibuffer when setting
excerpts is a no-op
- Limit excerpt recomputation in the project diff when diffs or
conflicts change to just the affected buffer
- Ignore diff events in the project diff that can't affect excerpt
boundaries

Also includes some drive-by improvements to the handling of merge
conflicts:
- Await initial conflicts parse when opening a conflict set (like
diffs), so we don't see an initial incorrect "no conflicts" state
- Make the project diff subscribe to conflicts directly instead of
indirecting through the editor (also like diffs)
- Instead of saving the affected buffer when resolving a conflict, just
avoid re-registering dirty buffers with the project diff, so that
excerpts for conflicts don't disappear quite so eagerly (once more: like
diffs)

The combination of these changes greatly cuts down the amount of time
spent syncing the `DisplayMap`, which is especially bad for the split
view.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved the performance of the project diff, especially in the
presence of merge conflicts
- Fixed conflicts disappearing too quickly from the project diff when
editing
- Fixed conflicts sometimes taking a while to appear in the project diff
during large merges
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