zed/crates/project/src
Max Brunsfeld f7a86967fd
Avoid holding worktree lock for a long time while updating large repos' git status (#12266)
Fixes https://github.com/zed-industries/zed/issues/9575
Fixes https://github.com/zed-industries/zed/issues/4294

### Problem

When a large git repository's `.git` folder changes (due to a `git
commit`, `git reset` etc), Zed needs to recompute the git status for
every file in that git repository. Part of computing the git status is
the *unstaged* part - the comparison between the content of the file and
the version in the git index. In a large git repository like `chromium`
or `linux`, this is inherently pretty slow.

Previously, we performed this git status all at once, and held a lock on
our `BackgroundScanner`'s state for the entire time. On my laptop, in
the `linux` repo, this would often take around 13 seconds.

When opening a file, Zed always refreshes the metadata for that file in
its in-memory snapshot of worktree. This is normally very fast, but if
another task is holding a lock on the `BackgroundScanner`, it blocks.

###  Solution

I've restructured how Zed handles Git statuses, so that when a git
repository is updated, we recompute files' git statuses in fixed-sized
batches. In between these batches, the `BackgroundScanner` is free to
perform other work, so that file operations coming from the main thread
will still be responsive.

Release Notes:

- Fixed a bug that caused long delays in opening files right after
performing a commit in very large git repositories.
2024-05-24 17:41:35 -07:00
..
connection_manager.rs WIP: remoting (#10085) 2024-04-11 15:36:35 -06:00
debounced_delay.rs
lsp_command.rs lsp: Use itemDefaults if sent along with completion items (#11902) 2024-05-16 13:26:07 +02:00
lsp_ext_command.rs
prettier_support.rs Allow formatting of unsaved buffers with prettier (#12095) 2024-05-22 06:19:32 +02:00
project.rs Avoid holding worktree lock for a long time while updating large repos' git status (#12266) 2024-05-24 17:41:35 -07:00
project_settings.rs Allow to toggle git hunk diffs (#11080) 2024-05-01 22:47:36 +03:00
project_tests.rs Allow clients to run Zed tasks on remote projects (#12199) 2024-05-24 22:26:57 +03:00
search.rs Implement serialization of assistant conversations, including tool calls and attachments (#11577) 2024-05-08 17:52:15 -04:00
search_history.rs project search: Persist search history across session (#9932) 2024-04-02 11:13:18 +02:00
task_inventory.rs Allow clients to run Zed tasks on remote projects (#12199) 2024-05-24 22:26:57 +03:00
terminals.rs Tidy up the code (#12116) 2024-05-22 14:36:15 +03:00