zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.15k stars 3.08k forks source link

expensive "git status" polling even with all git features disabled #14335

Open TPolzer opened 4 months ago

TPolzer commented 4 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I disabled all git related features, following

Unfortunately zed seems to poll a subprocess git --no-optional-locks status --porcelain=v1 --untracked-files=all -z . that uses significant amounts of CPU.

Running git --no-optional-locks status --porcelain=v1 --untracked-files=all -z . in the project root takes around 100ms, which is probably expected, since my repo is large. It would be nice to be able to just turn off git integration or ideally configure a polling frequency for polled (expensive) state?

Environment

Zed: v0.143.7 (Zed) OS: Linux Wayland debian unknown Memory: 31 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log


notpeter commented 4 months ago

There was one more missing from the list on #13304 (I added it just now):

  "outline_panel": {
    "git_status": false
  },

Can add that and let me know if that completely quiesces all git status activity?

SomeoneToIgnore commented 4 months ago

That would not change much, as there's a project panel and tabs having the same setting at least.

TPolzer commented 4 months ago

Would it be an option to place an inotify watch on the git root to know when to refresh git status?

joshuawarner32 commented 2 months ago

I'm running into a much more extreme version of this, on a very large internal repo (~500k tracked files!). In my case, the current behavior of periodically running this git status command makes zed basically unusable for any period of time on battery. Each invocation of this git status command takes 7-10 seconds, spiking to 100% CPU each time, and then very shortly later spiking CPU again.

I've essentially 100% switched back to VS Code when developing on said repo, since I strongly prefer not having my lap get hot if I'm not actively compiling/etc.

joshuawarner32 commented 2 months ago

This patch seems to work for me:

diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs
index 0461db4bf7..4084ee7511 100644
--- a/crates/worktree/src/worktree.rs
+++ b/crates/worktree/src/worktree.rs
@@ -4467,6 +4467,7 @@ impl BackgroundScanner {

     /// Update the git statuses for a given batch of entries.
     fn update_git_statuses(&self, job: UpdateGitStatusesJob) {
+        return;
         log::trace!("updating git statuses for repo {:?}", job.work_directory.0);
         let t0 = Instant::now();
         let Some(statuses) = job.repository.statuses(Path::new("")).log_err() else {

I don't really use/want git anything in my editor TBH, so not much lost.

joshuawarner32 commented 2 months ago

Would zed folks be open to a patch that adds a default-off "git": {"disable_status_updates": true} config (or whatever)?