Max Brunsfeld
7788eabec0
Avoid performance bottlenecks from git status calls during worktree scanning (#2777)
Closes
https://linear.app/zed-industries/issue/Z-2689/huge-slowdown-when-working-in-large-git-repositories-like-webkit
Closes https://github.com/zed-industries/community/issues/1770
In large git repositories (like Webkit), `git status` can be very slow.
And our current approach of retrieving git statuses (one by one as we
load paths), causes catastrophic slowdowns in these repos. This PR
further optimizes our retrieval of git statuses (started in
https://github.com/zed-industries/zed/pull/2728), so that when scanning
a directory, we only load git statuses once, in a single batch, at the
beginning of the scan.
There is still an initial lag when opening `WebKit` in Zed, while the
initial git status runs. But once this call completes, everything is
fast. Let's come back to this problem later.
For now, this makes Zed's directory scanning massively more efficient,
even in the case of normal-sized repos like `zed`. The git status code
was a huge percentage of zed's CPU usage when launching. Here is that
code, highlighted in a flamegraph before and after this change:
Before:

After:

Release Notes:
- Fixed a bug where project paths took a very long time to load when
working in large git repositories
([#1770](https://github.com/zed-industries/community/issues/1770))
2023-07-21 14:46:53 -07:00
..
2023-06-28 16:46:06 -04:00
2023-07-17 12:49:59 -06:00
2023-07-04 16:18:42 -04:00
2023-06-20 16:05:20 -07:00
2023-06-20 16:05:20 -07:00
2023-07-20 16:10:20 -04:00
2023-07-07 14:19:44 -04:00
2023-07-18 12:32:53 -04:00
2023-06-07 16:10:45 -07:00
2023-07-14 21:49:15 +02:00
2023-07-20 16:21:21 -04:00
2023-03-28 20:13:17 -07:00
2023-07-14 21:49:15 +02:00
2023-07-05 09:39:04 +02:00
2023-06-28 16:46:06 -04:00
2023-06-29 17:10:51 -07:00
2023-07-14 16:09:02 -07:00
2023-06-21 15:03:08 -04:00
2023-05-08 11:42:00 -04:00
2023-07-22 00:17:02 +03:00
2023-07-17 16:10:34 -04:00
2023-07-14 21:49:15 +02:00
2023-07-21 13:50:54 -07:00
2023-04-24 17:41:55 -07:00
2023-02-27 12:06:10 -08:00
2023-05-25 14:41:09 -04:00
2023-07-05 09:39:56 +02:00
2023-07-20 14:54:55 -04:00
2023-06-25 07:51:50 -06:00
2023-04-24 17:41:55 -07:00
2023-05-20 09:54:38 -06:00
2023-07-20 16:39:13 -07:00
2023-07-14 21:49:15 +02:00
2023-07-14 14:47:12 +03:00
2023-07-19 12:34:56 -07:00
2023-04-24 17:41:55 -07:00
2023-07-17 11:43:32 +02:00
2023-06-04 23:34:22 -04:00
2023-07-14 21:49:15 +02:00
2023-07-21 16:13:00 -04:00
2023-07-14 21:49:15 +02:00
2023-07-14 21:49:15 +02:00
2023-04-24 17:41:55 -07:00
2023-06-02 22:02:19 -04:00
2023-06-02 22:02:19 -04:00
2023-07-21 13:50:54 -07:00
2023-07-21 23:30:55 +03:00
2023-07-14 21:49:15 +02:00
2023-07-14 21:49:15 +02:00
2023-06-29 22:25:49 +03:00
2023-06-29 22:39:33 +03:00
2023-07-21 22:47:57 +03:00
2023-07-04 21:11:28 +03:00
2023-04-24 17:41:55 -07:00
2023-06-02 22:02:19 -04:00
2023-04-24 17:41:55 -07:00
2023-04-24 17:41:55 -07:00
2023-06-29 22:25:50 +03:00
2023-07-21 11:28:56 +03:00
2023-07-18 22:59:41 +03:00
2023-06-30 22:03:21 +03:00
2023-07-20 16:39:13 -07:00
2023-07-14 21:49:15 +02:00
2023-06-30 09:58:13 -04:00
2023-07-14 21:49:15 +02:00
2023-07-18 14:06:57 +03:00
2023-07-21 14:47:38 -04:00
2023-07-14 21:49:15 +02:00
2023-07-21 22:47:57 +03:00
2023-06-22 18:06:52 +02:00
2023-07-21 22:47:57 +03:00
2023-06-15 22:05:43 -07:00