git_graph: Improve loading time - #49736
Merged
Anthony-Eid merged 7 commits intoFeb 21, 2026
Merged
Conversation
This reduces the amount of rebuild of the graph data and actually fixes that we don't fetch the graph data twice. Co-authored-by: Anthony <anthony@zed.dev>
Contributor
|
yip yip hooray! |
This fixes that we don't fetch the graph data multiple times on initial repository loading events. By skipping the events when the initial snapshot of the repository is still on its empty state.
This commit fixes an issue where switching between repositories back and forward would show empty commits pane. This was because we cleared the graph data but never retriggerd that we needed to fetch from the initial graph data again.
RemcoSmitsDev
force-pushed
the
git-graph-improve-loading-time
branch
from
February 21, 2026 15:51
a585017 to
ac80534
Compare
RemcoSmitsDev
marked this pull request as ready for review
February 21, 2026 16:11
This removes the snapshot from the git graph and checks for the scan id instead. So if its bigger then 1 we now the repo has been initialized and we need to invalidate when we receive the a event from the git store. Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Contributor
|
Will add two tests then merge this |
Anthony-Eid
enabled auto-merge (squash)
February 21, 2026 22:53
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
This PR Fixes a loading performance regresssion inside the git graph. The main issue is that we always acted on the received repository events, this is good in 9 out of 10 cases except for the initial loading phase of the git graph. This is because we invalidate the graph data every time we receive a `GitStoreEvent::ActiveRepositoryChanged`, `RepositoryEvent::BranchChanged` or `RepositoryEvent::MergeHeadsChanged` event this still sounds good, but the caveat is that we receive these 3 events on initial repository loading. This happens when you start up Zed and is getting the active repository, branch ect. from your project. When it detects a repository/branch etc. it checks if it has been changed and emits an event for it. This is always the case for initial repository loading, because the active repository/branch always start as **None**. So receive an event for these non actual changes makes the git graph cancel its initial loading and start fetching again on every invalidated graph data call. We fixed this by checking the **scan_id** of the repo to check if the repo has been initialized, if its bigger then 1 we know we need to invalidate the data because it was a actual user change instead of a initial loading event. **Before** (note you see the loading state twice): https://github.com/user-attachments/assets/c25bfae1-0e2f-4c8b-a0d0-926acb33adff **After** (almost instant): https://github.com/user-attachments/assets/7e4ac116-65a2-4eb6-aa4c-37291d6acd0f ----- **Before** (switching repositories shows empty commits pane) https://github.com/user-attachments/assets/71b04285-49e7-47bb-9660-ad53bbf15c46 **After** (switching repositories shows correct graph from the cache) https://github.com/user-attachments/assets/38c33d93-f592-4440-b63b-567fda0fbeb8 Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - N/A --------- Co-authored-by: Anthony <anthony@zed.dev> Co-authored-by: Anthony Eid <hello@anthonyeid.me>
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
This PR Fixes a loading performance regresssion inside the git graph. The main issue is that we always acted on the received repository events, this is good in 9 out of 10 cases except for the initial loading phase of the git graph. This is because we invalidate the graph data every time we receive a `GitStoreEvent::ActiveRepositoryChanged`, `RepositoryEvent::BranchChanged` or `RepositoryEvent::MergeHeadsChanged` event this still sounds good, but the caveat is that we receive these 3 events on initial repository loading. This happens when you start up Zed and is getting the active repository, branch ect. from your project. When it detects a repository/branch etc. it checks if it has been changed and emits an event for it. This is always the case for initial repository loading, because the active repository/branch always start as **None**. So receive an event for these non actual changes makes the git graph cancel its initial loading and start fetching again on every invalidated graph data call. We fixed this by checking the **scan_id** of the repo to check if the repo has been initialized, if its bigger then 1 we know we need to invalidate the data because it was a actual user change instead of a initial loading event. **Before** (note you see the loading state twice): https://github.com/user-attachments/assets/c25bfae1-0e2f-4c8b-a0d0-926acb33adff **After** (almost instant): https://github.com/user-attachments/assets/7e4ac116-65a2-4eb6-aa4c-37291d6acd0f ----- **Before** (switching repositories shows empty commits pane) https://github.com/user-attachments/assets/71b04285-49e7-47bb-9660-ad53bbf15c46 **After** (switching repositories shows correct graph from the cache) https://github.com/user-attachments/assets/38c33d93-f592-4440-b63b-567fda0fbeb8 Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - N/A --------- Co-authored-by: Anthony <anthony@zed.dev> Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR Fixes a loading performance regresssion inside the git graph. The main issue is that we always acted on the received repository events, this is good in 9 out of 10 cases except for the initial loading phase of the git graph. This is because we invalidate the graph data every time we receive a
GitStoreEvent::ActiveRepositoryChanged,RepositoryEvent::BranchChangedorRepositoryEvent::MergeHeadsChangedevent this still sounds good, but the caveat is that we receive these 3 events on initial repository loading. This happens when you start up Zed and is getting the active repository, branch ect. from your project. When it detects a repository/branch etc. it checks if it has been changed and emits an event for it. This is always the case for initial repository loading, because the active repository/branch always start as None. So receive an event for these non actual changes makes the git graph cancel its initial loading and start fetching again on every invalidated graph data call.We fixed this by checking the scan_id of the repo to check if the repo has been initialized, if its bigger then 1 we know we need to invalidate the data because it was a actual user change instead of a initial loading event.
Before (note you see the loading state twice):
Screen.Recording.2026-02-18.at.17.17.36.mov
After (almost instant):
Screen.Recording.2026-02-20.at.18.11.22.mov
Before (switching repositories shows empty commits pane)
Screen.Recording.2026-02-21.at.16.24.06.mov
After (switching repositories shows correct graph from the cache)
Screen.Recording.2026-02-21.at.16.51.08.mov
Before you mark this PR as ready for review, make sure that you have:
Release Notes: