Re: [PATCH 1/2] repository: add core.indexLockTimeout
- From
D. Ben Knoble <ben.knoble@gmail.com>
- Date
- Oct 13, 2026, 21:40 UTC
- Message-ID
- <CALnO6CD8c+nZktineZjo6PkZbXXEQfKto-cvJvLW=_xjTPVCRA@mail.gmail.com>
- In-Reply-To
- <20261013172315.2997446-2-quark.zju@gmail.com>
Hi Jun,
On Tue, Oct 13, 2026 at 5:07 PM Jun Wu <quark.zju@gmail.com> wrote:
Show 11 quoted lines
> > From: Jun Wu <quark@meta.com> > > When an IDE runs `git status` periodically in the background, `status` > can take the index lock, and this prevents other commands like `add`, > `commit` from running. > > Commit 27344d6a6c (git: add --no-optional-locks option, 2017-09-27) > avoids the conflict by letting background `git --no-optional-locks status` > skip the index lock, at the cost of losing refreshed stat info, so > the next `status` has to re-hash files.
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?
I suppose I don't see how that causes things to slow down continually, but I bet I'm missing something :)
Show 13 quoted lines
> Approach the conflict from the other side: let non-status commands wait
> for the index lock. Mercurial and Sapling have a similar "waiting for wlock"
> behavior, and Git already has `core.{config,filesRef}LockTimeout`.
>
> Ideally all non-status commands can wait for the index lock. However,
> some code paths (e.g. `commit`) load the index without locking, then lock and
> write changes. It is already racy and the wait behavior would make it much
> worse. As a defense, waiting is disabled if index was already read.
>
> Default timeout is 1s, effective but not too long to avoid breaking potential
> user expectation (e.g. "an index.lock error means I should check whether a
> commit message editor is open somewhere"). Tests that are slowed down by the
> default timeout now set the timeout to 0.It feels weird to me to fix mostly-invisible behavior from external tools with a config option, though. I think of config *mostly* as user-facing (whether that user is a client of the Git CLI or configuring a server repo), and I don't see how we could teach users to look for this or know what a reasonable setting should be for themselves :/ Further, we already have a lot of config options! (I'm guilty of adding one recently, heh.) It can definitely be overwhelming for users to think about all the options, and I suspect many just don't as a result.
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?)