Skip to content

git_graph: Improve loading time - #49736

Merged
Anthony-Eid merged 7 commits into
zed-industries:mainfrom
RemcoSmitsDev:git-graph-improve-loading-time
Feb 21, 2026
Merged

git_graph: Improve loading time#49736
Anthony-Eid merged 7 commits into
zed-industries:mainfrom
RemcoSmitsDev:git-graph-improve-loading-time

Conversation

@RemcoSmitsDev

@RemcoSmitsDev RemcoSmitsDev commented Feb 20, 2026

Copy link
Copy Markdown
Collaborator

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):

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:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist

Release Notes:

  • N/A

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>
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Feb 20, 2026
@RemcoSmitsDev RemcoSmitsDev changed the title git_graph: Improve loading time of the git graph git_graph: Improve loading time Feb 20, 2026
@github-actions github-actions Bot added the community champion Issues filed by our amazing community champions! 🫶 label Feb 20, 2026
@Anthony-Eid

Copy link
Copy Markdown
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
RemcoSmitsDev force-pushed the git-graph-improve-loading-time branch from a585017 to ac80534 Compare February 21, 2026 15:51
@RemcoSmitsDev
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>
@Anthony-Eid

Copy link
Copy Markdown
Contributor

Will add two tests then merge this

@Anthony-Eid
Anthony-Eid enabled auto-merge (squash) February 21, 2026 22:53
@Anthony-Eid
Anthony-Eid merged commit bb368ce into zed-industries:main Feb 21, 2026
28 checks passed
@RemcoSmitsDev
RemcoSmitsDev deleted the git-graph-improve-loading-time branch February 28, 2026 21: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>
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 community champion Issues filed by our amazing community champions! 🫶

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants