Re: [PATCH 1/2] repository: add core.indexLockTimeout
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Oct 14, 2026, 16:29 UTC
- Message-ID
- <CALnO6CA=rnFfgvokMUQ5M-2xO+aqowF5KB1SSTYXT8hNYKUq+w@mail.gmail.com>
- In-Reply-To
- <20261014023812.2935165-1-quark.zju@gmail.com>
On Tue, Oct 13, 2026 at 10:38 PM Jun Wu <quark.zju@gmail.com> wrote:
Show 23 quoted lines
> > On Tue, 13 Oct 2026 17:40:01 -0400, D. Ben Knoble wrote: > > Hi Jun, > > Hi Ben, > > Thanks for taking a look. This area is a bit tricky, so let me try to > explain more clearly. > > > Interesting. That must be the slow down you mentioned in your cover > > letter? I'm trying to make sense of this. I think you're saying that > > not having the index lock means status would "lose" refreshed info: > > we're not throwing away the *existing* stat info, just the ones we > > recomputed for this "git --no-optional-locks status" invocation, > > right? > > Yes. A file's stat info might be updated without content change (e.g. > `touch`-ed) so the existing stat info can become outdated over time, and status > cannot use the stat fast path to confirm a file is not changed, so status falls > back to slow content check. Note: if the user runs a command like `add` that > writes the index, the performance can recover, but based on our experience, > users might not run such recovery commands for a long time, so they suffer from > slow status.
Makes sense.
> > I suppose I don't see how that causes things to slow down continually, > > but I bet I'm missing something :) > > To give some (hopefully useful) examples,
Sorry, I wonder if I wasn't clear: I read the cover letter as saying that performance worsens over time, and I'm not sure how that's implied. Maybe the idea is that more and more files need to be content-hashed, though?
Show 7 quoted lines
> > I applaud the effort for sensible defaults here, which I think will help. > > > > Anyway, maybe it's just me: if others are happy with this approach, > > great. I think I would prefer to see us try to address the underlying > > performance problems, though, if we can. (Maybe we can have some way > > for git-status to not throw away all its work, or some other good way > > to communicate to IDEs that want to poll?)
It does sound like others (Peff) think this is a fine approach, so I'll bow out now :)
Show 12 quoted lines
> By "address the underlying performance problems", do you mean: > > 1. Improve `status` performance so it takes index lock for a shorter duration. > It helps, but as long as `status` takes the lock, there is a chance it > conflicts with other commands. This series allows tools to drop > `--no-optional-locks`, which indirectly helps `status` performance. > 2. Improve `--no-optional-locks status` performance so it's fast. > This sounds like "lock-free writes to the index", which might require > a complex file format change. > 3. Switch IDEs from polling `git status` to fsmonitor-style `status` notification. > This helps. But similar to 1, reducing `status` frequency alone does not > address the root issue.
These all sound like great ideas! I actually didn't have a concrete suggestion, other than trying to address the root cause rather than (IMO) band-aiding the surface.
Looking a bit more at how my editor integration works (tpope's fugitive for Vim), it seems to *not* use --no-optional-locks and (presumably) avoids the issues you're seeing by limiting background refreshes to specific events [1] and doing some kind of caching, but I haven't really worked through it all and I'm not sure how easy it would be to extract generic ideas for different editors :) It's also possible I just haven't ever run into the situation where --no-optional-locks would have helped, so might be a moot point.
[1]: https://github.com/tpope/vim-fugitive/tree/3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0
-- D. Ben Knoble