Skip to content

sidebar: Improve performance of rebuild_contents - #57717

Merged
Veykril merged 2 commits into
mainfrom
push-mrnsyowvqsxy
May 27, 2026
Merged

sidebar: Improve performance of rebuild_contents#57717
Veykril merged 2 commits into
mainfrom
push-mrnsyowvqsxy

Conversation

@Veykril

@Veykril Veykril commented May 26, 2026

Copy link
Copy Markdown
Member

Release Notes:

  • N/A or Added/Fixed/Improved ...

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 26, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 26, 2026
@Veykril
Veykril force-pushed the push-mrnsyowvqsxy branch 3 times, most recently from a78fc75 to 79a1add Compare May 26, 2026 10:31
.iter()
.filter(|(_, tracked)| tracked.has_edits(cx))
.map(|(buffer, tracked)| (buffer.clone(), tracked.diff.clone()))
.collect()

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.

Hot allocation, some callers, especially the sidebar iterates through at once (via diff_stats) wasting multiple allocations due to the use of BTreeMap, so let the caller decide instead. Most callers are also fine with a Vec, as the iteration order is already guaranteed

.flat_map(|ws| all_thread_infos_for_workspace(ws, cx));

let mut threads: Vec<ThreadEntry> = Vec::new();
let mut threads: Vec<Arc<ThreadEntry>> = Vec::new();

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.

We later sort this and ThreadEntry is massive with ~700 bytes in size, causing us to spend a significant time in memcpy-ing around when sorting a larger number of threads

@Veykril
Veykril force-pushed the push-mrnsyowvqsxy branch 2 times, most recently from 4f1c6de to 23296af Compare May 26, 2026 10:39
@Veykril
Veykril force-pushed the push-mrnsyowvqsxy branch from 23296af to de9d5e7 Compare May 27, 2026 07:47
@Veykril
Veykril requested a review from osiewicz May 27, 2026 07:58
@Veykril
Veykril added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit 6555ac3 May 27, 2026
33 checks passed
@Veykril
Veykril deleted the push-mrnsyowvqsxy branch May 27, 2026 10:34
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 2, 2026
)

Release Notes:

- N/A or Added/Fixed/Improved ...
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 8, 2026
Follow up on zed-industries#57717
Release Notes:

- N/A or Added/Fixed/Improved ...
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
)

Release Notes:

- N/A or Added/Fixed/Improved ...
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Follow up on zed-industries#57717
Release Notes:

- N/A or Added/Fixed/Improved ...
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
)

Release Notes:

- N/A or Added/Fixed/Improved ...
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Follow up on zed-industries#57717
Release Notes:

- N/A or Added/Fixed/Improved ...
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