Skip to content

multibuffer: Speed up anchor resolution by avoiding an excerpts seek#53340

Merged
cole-miller merged 2 commits intomainfrom
less-buffer-for-path
Apr 7, 2026
Merged

multibuffer: Speed up anchor resolution by avoiding an excerpts seek#53340
cole-miller merged 2 commits intomainfrom
less-buffer-for-path

Conversation

@cole-miller
Copy link
Copy Markdown
Member

@cole-miller cole-miller commented Apr 7, 2026

Before, every creation of AnchorSeekTarget called MultiBufferSnapshot::buffer_for_path, which seeks the excerpts sum tree. Now we avoid that by

  • looking up the buffer snapshot for the anchor's buffer in the buffers map (keyed by BufferId)
  • handling the case where the anchor's buffer doesn't exist at the original path key with a separate AnchorSeekTarget::Missing variant

We also added a separate optimization to AnchorSeekTarget::cmp, to skip the full PathKey comparison when the cursor's PathKeyIndex is the same as the anchor's. This should help with singleton multibuffers.

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:

  • N/A

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Apr 7, 2026
@cole-miller cole-miller requested a review from ConradIrwin April 7, 2026 22:11
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Apr 7, 2026
Copy link
Copy Markdown
Member

@ConradIrwin ConradIrwin left a comment

Choose a reason for hiding this comment

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

Makes sense to me, thanks!

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
@cole-miller cole-miller enabled auto-merge (squash) April 7, 2026 22:25
@cole-miller cole-miller merged commit aa81505 into main Apr 7, 2026
31 checks passed
@cole-miller cole-miller deleted the less-buffer-for-path branch April 7, 2026 22:37
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