git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Jun WuNext: Junio C Hamano
Message 5 of 20 in “Add a way to wait for index lock”
  1. 0/2 Add a way to wait for index lockJun Wu, Oct 13, 2026
  2. 1/2 repository: add core.indexLockTimeoutJun Wu, Oct 13, 2026
  3. D. Ben KnobleOct 13, 2026
  4. Jun WuOct 14, 2026
  5. D. Ben KnobleOct 14, 2026
  6. Junio C HamanoOct 13, 2026
  7. Jun WuOct 14, 2026
  8. Ben KnobleOct 19, 2026
  9. 2/2 commit: lock index before readingJun Wu, Oct 13, 2026
  10. Jeff KingOct 14, 2026
  11. Jun WuOct 15, 2026
  12. Junio C HamanoOct 13, 2026
  13. Jun WuOct 14, 2026
  14. Jeff KingOct 14, 2026
  15. 0/4 Wait for the index lock instead of failingJun Wu, Oct 17, 2026
  16. 1/4 repository: add repo_try_hold_locked_index()Jun Wu, Oct 17, 2026
  17. 2/4 repository: add core.indexLockTimeoutJun Wu, Oct 17, 2026
  18. 3/4 commit: fix write raceJun Wu, Oct 17, 2026
  19. 4/4 reset: fix write raceJun Wu, Oct 17, 2026
  20. Mihai CosmaOct 22, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.