ZIm/crates/project/src
Max Brunsfeld a01d973477
More git status optimizations (#2779)
Follow-up to https://github.com/zed-industries/zed/pull/2777
Refs https://github.com/zed-industries/community/issues/1770

In this PR, I reworked the way that git statuses are retrieved. In a
huge repository like `WebKit`, the really slow part of computing a list
of git statuses is the *unstaged* portion of the diff. For the *staged*
diff, `git` can avoid comparing the contents of unchanged directories,
because the index contains hashes of every tree. But for the *unstaged*
portion, Git needs to compare every file in the worktree against the
index. In the common case, when there are no changes, it's enough to
check the `mtime` of every file (because the index stores the mtimes of
files when they are added). But this still requires an `lstat` call to
retrieve each file's metadata.

I realized that this is redundant work, because the worktree is
*already* calling `lstat` on every file, and caching their metadata. So
in this PR, I've changed the `Repository` API so that there are separate
methods for retrieving a file's *staged* and *unstaged* statuses. The
*staged* statuses are retrieved in one giant batch, like before, to
reduce our git calls (which also have an inherent cost). But the
`unstaged` statuses are retrieved one-by-one, after we load files'
mtimes. Often, all that's required is an index lookup, and an mtime
comparison.

With this optimization, it once again becomes pretty responsive to open
`WebKit` or `chromium` in Zed.

Release Notes:

- Optimized the loading of project file when working in very large git
repositories
2023-07-24 11:23:32 -07:00
..
ignore.rs Use absolute paths to compute ignored status 2022-07-08 11:19:21 +02:00
lsp_command.rs Do not resolve completions if extra edits are available 2023-07-12 20:28:16 +03:00
project.rs Focus project panel on directory select 2023-07-23 00:12:25 +03:00
project_settings.rs Remove concept of git diff refresh from Item trait 2023-05-25 14:29:28 -04:00
project_tests.rs Avoid redundant FS scans when LSPs changed watched files 2023-06-29 11:35:49 -07:00
search.rs Optimize matching of multiple file-watch globs using the globset crate 2023-05-19 09:13:34 -07:00
terminals.rs Remove optional path argument when getting settings 2023-05-17 15:05:20 -07:00
worktree.rs Optimize full file status via passing in known file mtime 2023-07-22 11:53:26 -07:00
worktree_tests.rs Fix regression in handling git FS events (#2670) 2023-06-30 11:40:49 -07:00