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

Re: [PATCH v2 0/4] Wait for the index lock instead of failing

From
MCMihai Cosma <mcosma@gmail.com>
Date
Oct 22, 2026, 18:49 UTC
Message-ID
<20261022184906.3679783-1-mcosma@gmail.com>
In-Reply-To
<20261017073231.3357477-1-quark.zju@gmail.com>
Hi Jun,

I've been working on the same problem from the status side and just sent a two-patch series:

  https://lore.kernel.org/git/20261022184420.3648771-1-mcosma@gmail.com/

Status takes index.lock before collecting and holds it to the end, even when it has nothing to write, so it's often the process "git add" and "git commit" end up waiting on. My series makes it lock only to write. On top of your v2, in a gcc checkout with status running in a loop, the slowest of 200 "git add" runs went from 1020 ms (one hit your 1s timeout) to 160 ms.

The two only conflict on the lock call in cmd_status() that your 1/4 renames, so whichever lands second can pick up the other's change. My first patch also makes repo_update_index_if_able()'s check work under index.skipHash, which the read-then-lock callers your series leaves alone rely on.

Thanks, Mihai

Previous: Jun Wu
Message 20 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.