{"thread":{"id":"66633","subject":"[PATCH 0/2] status: stop holding index.lock while collecting","startedAt":"2026-10-22T18:44:18Z","lastAt":"2026-10-23T19:50:55Z","messageCount":5,"participants":["Mihai Cosma","Junio C Hamano","Jun Wu"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"555895","messageId":"20261022184420.3648771-1-mcosma@gmail.com","threadId":"66633","inReplyTo":null,"subject":"[PATCH 0/2] status: stop holding index.lock while collecting","fromName":"Mihai Cosma","fromEmail":"mcosma@gmail.com","sentAt":"2026-10-22T18:44:18Z","receivedAt":"2026-10-22T18:44:18Z","isPatch":true,"sender":{"key":"mcosma@gmail.com","avatar":null},"body":"Background \"git status\" runs from editors and shell prompts hold\nindex.lock for their whole run, so a \"git add\" or \"git commit\" run at\nthe same time fails. Patch 2 makes status take the lock only to write,\nand only when it has something to write.\n\nPatch 1 fixes a bug that patch 2 relies on but that exists on its own:\nunder index.skipHash (on with feature.manyFiles and in Scalar repos),\nthe check that stops status from overwriting a concurrently updated\nindex passes for any index, so status can silently revert a \"git add\",\nalso on 2.56.0. It applies to maint and can go in alone. There's a\nreproduction below its \"---\".\n\nThis overlaps with Jun Wu's \"Wait for the index lock instead of\nfailing\" series, and the two fit together: his makes writers wait for\nthe lock, this makes status hold it rarely and briefly. They only\nconflict on the one lock call in cmd_status(), which his series renames\nto repo_try_hold_locked_index(). I'm happy to rebase onto it. On top of\nhis v2, the slowest \"git add\" in the clean case below went from 1020 ms\n(one failure at his 1s timeout) to 160 ms.\n\nNumbers on master, from a gcc checkout (124,311 files) on Linux, timing\n200 \"git add\" runs while \"git status\" runs in a loop. \"Active\" touches\na tracked file before each status, so every status run writes the\nindex:\n\n                       master      this series\n  clean   failed       104/200     0/200\n          p95 (ms)     114         128\n  active  failed       123/200     47/200\n          p95 (ms)     117         111\n\nFailed runs on master return fast, which is why its timings look good.\nIn the active case status still holds the lock while it writes, about\n76 ms for gcc's 14 MB index, and that's the part a short wait like\nJun's covers.\n\nThe script, run from the top of the checkout as \"bash measure.sh clean\"\nor \"bash measure.sh active\":\n\n  touched=$(git ls-files | head -1); echo x >measure-file\n  ( end=$((SECONDS+60)); while [ $SECONDS -lt $end ]; do\n      [ \"$1\" = active ] && touch \"$touched\"\n      git status --porcelain >/dev/null 2>&1\n    done ) &\n  sleep 1\n  for i in $(seq 200); do\n      s=$(date +%s%N); git add measure-file 2>/dev/null; rc=$?\n      echo $(( ($(date +%s%N) - s) / 1000000 )) $rc; sleep 0.05\n  done | sort -n | awk '{t[NR]=$1; f+=($2!=0)} END {\n      print \"median\", t[int(NR/2)], \"p95\", t[int(NR*0.95)],\n            \"max\", t[NR], \"ms, failed\", f \"/\" NR }'\n  wait; git rm -q --cached measure-file; rm measure-file\n\nThe skipHash tests turn split index off, because index.skipHash and a\nsplit index don't work together at all today: with both set, \"git add\"\nstages nothing, which Peff noticed back in 2023 [1].\n\n[1] https://lore.kernel.org/git/20230629083859.GA585934@coredump.intra.peff.net/\n\nUsed Claude Opus 5.5, and Gemini 4 Argon for review.\n\nMihai Cosma (2):\n  read-cache: verify skipHash index by stat data\n  status: lock the index only to write it\n\n builtin/commit.c  |  14 +++---\n read-cache-ll.h   |   1 +\n read-cache.c      |  59 +++++++++++++++++++++++--\n repository.h      |   7 +++\n t/t7508-status.sh | 108 ++++++++++++++++++++++++++++++++++++++++++++++\n unpack-trees.c    |   1 +\n 6 files changed, 178 insertions(+), 12 deletions(-)\n\n\nbase-commit: 47fdf2208c5b94c8cc01c106b8f7c85efb91c926\n-- \n2.56.0\n\n\n"},{"id":"555896","messageId":"20261022184420.3648771-2-mcosma@gmail.com","threadId":"66633","inReplyTo":"20261022184420.3648771-1-mcosma@gmail.com","subject":"[PATCH 1/2] read-cache: verify skipHash index by stat data","fromName":"Mihai Cosma","fromEmail":"mcosma@gmail.com","sentAt":"2026-10-22T18:44:19Z","receivedAt":"2026-10-22T18:44:19Z","isPatch":true,"sender":{"key":"mcosma@gmail.com","avatar":null},"body":"\"git status\" and other commands read and refresh the index without the\nlock, then write it only if repo_update_index_if_able() finds the\nfile's trailing checksum unchanged, so they cannot undo an update made\nby another process in between.\n\nSince ee1f0c242e (read-cache: add index.skipHash config option,\n2023-01-06), the trailer can be all zeros, and feature.manyFiles and\nScalar turn that on. The check then passes for any index on disk, and\na \"git add\" that lands between status reading the index and taking the\nlock is silently reverted.\n\nWhen the recorded checksum is null, check instead that the stat data of\nthe index file is unchanged since it was read or written, apart from\nthe ctime, which renaming the lockfile into place changes. Ignore\ncore.checkStat and core.useNanosec here: a false match loses an\nupdate, while a false mismatch only skips an optional write. On Windows,\nwhich reports no inode numbers, this rests on the size and the mtime,\nso two same-size rewrites within one 100ns tick could still be missed.\n\nunpack_trees() builds a new index from the one it was given and copies\nits checksum, so copy the stat data along with it.\n\nAssisted-by: Claude Opus 5.5, Gemini 4 Argon\nSigned-off-by: Mihai Cosma <mcosma@gmail.com>\n---\nTo see the bug without building anything, this loses a \"git add\" with\nv2.56.0 (it prints nothing) and keeps it with this patch (it prints\n\"b\"). The fsmonitor hook stands in for another process that\nupdates the index while status is reading it:\n\n  git init -q repro && cd repro &&\n  git config index.skipHash true &&\n  echo a >a && git add a && git commit -qm a &&\n  # this hook runs while status reads the index: stage b behind its back\n  printf '%s\\n' '#!/bin/sh' \\\n    'test -f b && ! test -f .git/done && >.git/done && git add b' \\\n    'exit 1' >.git/hook &&\n  chmod +x .git/hook &&\n  git config core.fsmonitor .git/hook &&\n  git config core.fsmonitorHookVersion 2 &&\n  touch -d '1 hour ago' a && echo b >b &&\n  git status >/dev/null &&\n  git diff --cached --name-only\n\n read-cache-ll.h   |  1 +\n read-cache.c      | 37 ++++++++++++++++++++++++++++++++++++-\n t/t7508-status.sh | 41 +++++++++++++++++++++++++++++++++++++++++\n unpack-trees.c    |  1 +\n 4 files changed, 79 insertions(+), 1 deletion(-)\n\ndiff --git a/read-cache-ll.h b/read-cache-ll.h\nindex 066dd8bc3b..a45aff02ea 100644\n--- a/read-cache-ll.h\n+++ b/read-cache-ll.h\n@@ -181,6 +181,7 @@ struct index_state {\n \tstruct hashmap name_hash;\n \tstruct hashmap dir_hash;\n \tstruct object_id oid;\n+\tstruct stat_data file_stat;\n \tstruct untracked_cache *untracked;\n \tchar *fsmonitor_last_update;\n \tstruct ewah_bitmap *fsmonitor_dirty;\ndiff --git a/read-cache.c b/read-cache.c\nindex c4cf08a3a3..58bae677b8 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -2309,6 +2309,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n \n \tistate->timestamp.sec = st.st_mtime;\n \tistate->timestamp.nsec = ST_MTIME_NSEC(st);\n+\tfill_stat_data(&istate->file_stat, &st);\n \n \t/* if we created a thread, join it otherwise load the extensions on the primary thread */\n \tif (extension_offset) {\n@@ -2699,9 +2700,35 @@ static int ce_write_entry(struct hashfile *f, struct cache_entry *ce,\n \treturn 0;\n }\n \n+/*\n+ * Whether the index file is still the one whose stat data was recorded\n+ * when the index was read or written. This stands in for the checksum\n+ * of an index written without one, so unlike match_stat_data() it\n+ * always compares the inode and the mtime to the nanosecond, whatever\n+ * core.checkStat and core.useNanosec say: a false \"unchanged\" would\n+ * discard an update made by another process, while a false \"changed\"\n+ * only skips an opportunistic write. The ctime is left out because\n+ * renaming the written lockfile into place changes it.\n+ */\n+static int index_file_unchanged(const struct stat_data *sd, struct stat *st)\n+{\n+\tstruct stat_data now;\n+\n+\tfill_stat_data(&now, st);\n+\treturn sd->sd_mtime.sec == now.sd_mtime.sec &&\n+\t       sd->sd_mtime.nsec == now.sd_mtime.nsec &&\n+\t       sd->sd_dev == now.sd_dev &&\n+\t       sd->sd_ino == now.sd_ino &&\n+\t       sd->sd_uid == now.sd_uid &&\n+\t       sd->sd_gid == now.sd_gid &&\n+\t       sd->sd_size == now.sd_size;\n+}\n+\n /*\n  * This function verifies if index_state has the correct sha1 of the\n- * index file.  Don't die if we have any other failure, just return 0.\n+ * index file, or, when the index was written without a checksum\n+ * (index.skipHash), that the file's stat data has not changed. Don't\n+ * die if we have any other failure, just return 0.\n  */\n static int verify_index_from(const struct index_state *istate, const char *path)\n {\n@@ -2720,6 +2747,13 @@ static int verify_index_from(const struct index_state *istate, const char *path)\n \tif (fstat(fd, &st))\n \t\tgoto out;\n \n+\tif (is_null_oid(&istate->oid)) {\n+\t\tif (!index_file_unchanged(&istate->file_stat, &st))\n+\t\t\tgoto out;\n+\t\tclose(fd);\n+\t\treturn 1;\n+\t}\n+\n \tif (st.st_size < sizeof(struct cache_header) + the_hash_algo->rawsz)\n \t\tgoto out;\n \n@@ -3098,6 +3132,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,\n \t}\n \tistate->timestamp.sec = (unsigned int)st.st_mtime;\n \tistate->timestamp.nsec = ST_MTIME_NSEC(st);\n+\tfill_stat_data(&istate->file_stat, &st);\n \ttrace_performance_since(start, \"write index, changed mask = %x\", istate->cache_changed);\n \n \ttrace2_data_intmax(\"index\", istate->repo, \"write/version\",\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex 0fd7c79911..c045a651f8 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1681,6 +1681,47 @@ test_expect_success '--no-optional-locks prevents index update' '\n \t! test_is_magic_mtime .git/index\n '\n \n+# The fsmonitor hook runs while status reads the index, before status\n+# takes the lock, and stands in for a user command that updates the\n+# index at that moment.\n+for skip_hash in false true\n+do\n+\ttest_expect_success \"status keeps an index update made after it read the index (index.skipHash=$skip_hash)\" '\n+\t\ttest_when_finished \"rm -rf update-after-read\" &&\n+\t\tgit init update-after-read &&\n+\t\t(\n+\t\t\tcd update-after-read &&\n+\t\t\tif test $skip_hash = true\n+\t\t\tthen\n+\t\t\t\t# index.skipHash does not work with a split index.\n+\t\t\t\tsane_unset GIT_TEST_SPLIT_INDEX\n+\t\t\tfi &&\n+\t\t\tgit config index.skipHash $skip_hash &&\n+\t\t\ttest_commit base &&\n+\t\t\twrite_script .git/fsmonitor-hook <<-\\EOF &&\n+\t\t\t# Act once; the \"git add\" below runs this hook again.\n+\t\t\tif test -f to-add && ! test -f .git/hook-ran\n+\t\t\tthen\n+\t\t\t\t>.git/hook-ran &&\n+\t\t\t\tgit add to-add\n+\t\t\tfi\n+\t\t\t# Report failure so that status checks every path itself.\n+\t\t\texit 1\n+\t\t\tEOF\n+\t\t\tgit config core.fsmonitorHookVersion 2 &&\n+\t\t\tgit config core.fsmonitor .git/fsmonitor-hook &&\n+\t\t\tgit status &&\n+\t\t\ttest-tool chmtime -60 base.t &&\n+\t\t\techo content >to-add &&\n+\t\t\tgit status &&\n+\t\t\ttest_path_is_file .git/hook-ran &&\n+\t\t\techo to-add >expect &&\n+\t\t\tgit diff --cached --name-only >actual &&\n+\t\t\ttest_cmp expect actual\n+\t\t)\n+\t'\n+done\n+\n test_expect_success 'racy timestamps will be fixed for clean worktree' '\n \techo content >racy-dirty &&\n \techo content >racy-racy &&\ndiff --git a/unpack-trees.c b/unpack-trees.c\nindex 1802809ad3..d6a859420f 100644\n--- a/unpack-trees.c\n+++ b/unpack-trees.c\n@@ -1959,6 +1959,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options\n \t\t\tinit_split_index(&o->internal.result);\n \t}\n \toidcpy(&o->internal.result.oid, &o->src_index->oid);\n+\to->internal.result.file_stat = o->src_index->file_stat;\n \to->internal.merge_size = len;\n \tmark_all_ce_unused(o->src_index);\n \n-- \n2.56.0\n\n\n"},{"id":"555897","messageId":"20261022184420.3648771-3-mcosma@gmail.com","threadId":"66633","inReplyTo":"20261022184420.3648771-1-mcosma@gmail.com","subject":"[PATCH 2/2] status: lock the index only to write it","fromName":"Mihai Cosma","fromEmail":"mcosma@gmail.com","sentAt":"2026-10-22T18:44:20Z","receivedAt":"2026-10-22T18:44:20Z","isPatch":true,"sender":{"key":"mcosma@gmail.com","avatar":null},"body":"Editors and shell prompts run \"git status\" in the background. Status\ntakes index.lock before collecting and holds it to the end, even when\nit writes nothing, so a \"git add\" or \"git commit\" run meanwhile fails\nwith \"index.lock: File exists\".\n\nThe lock does not need to cover the collection, because\nrepo_update_index_if_able() refuses to write an index that changed\nsince status read it. 226c051adb (status: enable untracked cache,\n2015-03-08) moved the write after wt_status_collect() to save the\nuntracked cache, but left the lock where it was.\n\nAdd repo_lock_and_update_index_if_able(), which takes the lock only if\nthe index has something to write, and call it after collecting. When\nthere is nothing to write, status no longer creates index.lock; when\nthere is, it holds the lock only for the write. In a clean gcc checkout\nwith status running in a loop, 104 of 200 \"git add\" runs failed before\nand none after.\n\nAssisted-by: Claude Opus 5.5, Gemini 4 Argon\nSigned-off-by: Mihai Cosma <mcosma@gmail.com>\n---\n builtin/commit.c  | 14 +++++-----\n read-cache.c      | 22 +++++++++++++---\n repository.h      |  7 +++++\n t/t7508-status.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 99 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 0e750f6157..851125f1e9 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1543,7 +1543,6 @@ struct repository *repo UNUSED)\n \tstatic const char *rename_score_arg = (const char *)-1;\n \tstatic struct wt_status s;\n \tunsigned int progress_flag = 0;\n-\tint fd;\n \tstruct object_id oid;\n \tstatic struct option builtin_status_options[] = {\n \t\tOPT__VERBOSE(&verbose, N_(\"be verbose\")),\n@@ -1631,11 +1630,6 @@ struct repository *repo UNUSED)\n \t\t      REFRESH_QUIET|REFRESH_UNMERGED|progress_flag,\n \t\t      &s.pathspec, NULL, NULL);\n \n-\tif (use_optional_locks())\n-\t\tfd = repo_hold_locked_index(the_repository, &index_lock, 0);\n-\telse\n-\t\tfd = -1;\n-\n \ts.is_initial = repo_get_oid(the_repository, s.reference, &oid) ? 1 : 0;\n \tif (!s.is_initial)\n \t\toidcpy(&s.oid_commit, &oid);\n@@ -1654,8 +1648,12 @@ struct repository *repo UNUSED)\n \n \twt_status_collect(&s);\n \n-\tif (0 <= fd)\n-\t\trepo_update_index_if_able(the_repository, &index_lock);\n+\t/*\n+\t * Lock only after collecting (the slow part), so that status\n+\t * does not block other commands while it works.\n+\t */\n+\tif (use_optional_locks())\n+\t\trepo_lock_and_update_index_if_able(the_repository);\n \n \tif (s.relative_paths)\n \t\ts.prefix = prefix;\ndiff --git a/read-cache.c b/read-cache.c\nindex 58bae677b8..1d2b97c429 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -2790,17 +2790,33 @@ int has_racy_timestamp(struct index_state *istate)\n \treturn 0;\n }\n \n+static int index_needs_write(struct index_state *istate)\n+{\n+\treturn istate->cache_changed || has_racy_timestamp(istate);\n+}\n+\n void repo_update_index_if_able(struct repository *repo,\n \t\t\t       struct lock_file *lockfile)\n {\n-\tif ((repo->index->cache_changed ||\n-\t     has_racy_timestamp(repo->index)) &&\n-\t    repo_verify_index(repo))\n+\tif (index_needs_write(repo->index) && repo_verify_index(repo))\n \t\twrite_locked_index(repo->index, lockfile, COMMIT_LOCK);\n \telse\n \t\trollback_lock_file(lockfile);\n }\n \n+void repo_lock_and_update_index_if_able(struct repository *repo)\n+{\n+\tstruct lock_file lock = LOCK_INIT;\n+\n+\tif (!index_needs_write(repo->index) ||\n+\t    repo_hold_locked_index(repo, &lock, 0) < 0)\n+\t\treturn;\n+\tif (repo_verify_index(repo))\n+\t\twrite_locked_index(repo->index, &lock, COMMIT_LOCK);\n+\telse\n+\t\trollback_lock_file(&lock);\n+}\n+\n static int record_eoie(void)\n {\n \tint val;\ndiff --git a/repository.h b/repository.h\nindex 11f5c2ed10..82738d03a3 100644\n--- a/repository.h\n+++ b/repository.h\n@@ -295,6 +295,13 @@ int repo_read_index_unmerged(struct repository *);\n  */\n void repo_update_index_if_able(struct repository *, struct lock_file *);\n \n+/*\n+ * Like repo_update_index_if_able(), but take the lock only if the index\n+ * has something to write, so that a caller that read the index without\n+ * the lock holds it only for the write.\n+ */\n+void repo_lock_and_update_index_if_able(struct repository *);\n+\n /*\n  * Return 1 if upgrade repository format to target_version succeeded,\n  * 0 if no upgrade is necessary, and -1 when upgrade is not possible.\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex c045a651f8..e10c961268 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1722,6 +1722,73 @@ do\n \t'\n done\n \n+# While status collects, it runs \"git status\" in the submodule, which\n+# runs the submodule's fsmonitor hook. The hook stands in for a user\n+# command that updates the superproject's index at that moment.\n+setup_index_update_during_collection () {\n+\tgit init \"$1\" &&\n+\t(\n+\t\tcd \"$1\" &&\n+\t\ttest_commit base &&\n+\t\tgit init sub &&\n+\t\ttest_commit -C sub sub-base &&\n+\t\tgit -c advice.addEmbeddedRepo=false add sub &&\n+\t\tgit commit -m \"add sub\" &&\n+\t\twrite_script sub/.git/fsmonitor-hook <<-\\EOF &&\n+\t\t# The hook runs in the submodule with GIT_DIR exported for it;\n+\t\t# clear that before working in the superproject.\n+\t\tunset $(git rev-parse --local-env-vars)\n+\t\tif test -f ../to-add\n+\t\tthen\n+\t\t\tgit -C .. add to-add\n+\t\tfi\n+\t\t# Report failure so that status checks every path itself.\n+\t\texit 1\n+\t\tEOF\n+\t\tgit -C sub config core.fsmonitorHookVersion 2 &&\n+\t\tgit -C sub config core.fsmonitor .git/fsmonitor-hook\n+\t)\n+}\n+\n+test_expect_success 'status does not block index updates while collecting' '\n+\ttest_when_finished \"rm -rf update-while-collecting\" &&\n+\tsetup_index_update_during_collection update-while-collecting &&\n+\t(\n+\t\tcd update-while-collecting &&\n+\t\tgit status &&\n+\t\techo content >to-add &&\n+\t\tgit status &&\n+\t\techo to-add >expect &&\n+\t\tgit diff --cached --name-only >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n+for skip_hash in false true\n+do\n+\ttest_expect_success \"status refresh does not overwrite an index update made while collecting (index.skipHash=$skip_hash)\" '\n+\t\ttest_when_finished \"rm -rf refresh-while-collecting\" &&\n+\t\t(\n+\t\t\tif test $skip_hash = true\n+\t\t\tthen\n+\t\t\t\t# index.skipHash does not work with a split index.\n+\t\t\t\tsane_unset GIT_TEST_SPLIT_INDEX\n+\t\t\tfi &&\n+\t\t\tsetup_index_update_during_collection refresh-while-collecting &&\n+\t\t\tcd refresh-while-collecting &&\n+\t\t\tgit config index.skipHash $skip_hash &&\n+\t\t\tgit update-index --force-write-index &&\n+\t\t\tgit status &&\n+\t\t\ttest-tool chmtime -60 base.t &&\n+\t\t\techo content >to-add &&\n+\t\t\tgit status &&\n+\t\t\techo to-add >expect &&\n+\t\t\tgit diff --cached --name-only >actual &&\n+\t\t\ttest_cmp expect actual\n+\t\t)\n+\t'\n+done\n+\n test_expect_success 'racy timestamps will be fixed for clean worktree' '\n \techo content >racy-dirty &&\n \techo content >racy-racy &&\n-- \n2.56.0\n\n\n"},{"id":"556096","messageId":"xmqqik2s5kt3.fsf@gitster.g","threadId":"66633","inReplyTo":"20261022184420.3648771-1-mcosma@gmail.com","subject":"Re: [PATCH 0/2] status: stop holding index.lock while collecting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-23T18:33:12Z","receivedAt":"2026-10-23T18:33:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mihai Cosma <mcosma@gmail.com> writes:\n\n> This overlaps with Jun Wu's \"Wait for the index lock instead of\n> failing\" series, and the two fit together: his makes writers wait for\n> the lock, this makes status hold it rarely and briefly. They only\n> conflict on the one lock call in cmd_status(), which his series renames\n> to repo_try_hold_locked_index(). I'm happy to rebase onto it. On top of\n> his v2, the slowest \"git add\" in the clean case below went from 1020 ms\n> (one failure at his 1s timeout) to 160 ms.\n\nPerhaps you two can work together and send a single consolidated series?\n\nThanks.\n\n"},{"id":"556103","messageId":"20261023195101.1087983-1-quark.zju@gmail.com","threadId":"66633","inReplyTo":"xmqqik2s5kt3.fsf@gitster.g","subject":"Re: [PATCH 0/2] status: stop holding index.lock while collecting","fromName":"Jun Wu","fromEmail":"quark.zju@gmail.com","sentAt":"2026-10-23T19:50:55Z","receivedAt":"2026-10-23T19:50:55Z","isPatch":true,"sender":{"key":"quark.zju@gmail.com","avatar":null},"body":"Hi Junio,\n\nOn Fri, 23 Oct 2026 11:33:12 -0700, Junio C Hamano wrote:\n> Mihai Cosma <mcosma@gmail.com> writes:\n>\n> > This overlaps with Jun Wu's \"Wait for the index lock instead of\n> > failing\" series, and the two fit together: his makes writers wait for\n> > the lock, this makes status hold it rarely and briefly. They only\n> > conflict on the one lock call in cmd_status(), which his series renames\n> > to repo_try_hold_locked_index(). I'm happy to rebase onto it. On top of\n> > his v2, the slowest \"git add\" in the clean case below went from 1020 ms\n> > (one failure at his 1s timeout) to 160 ms.\n>\n> Perhaps you two can work together and send a single consolidated series?\n\nI think the two series are relatively independent:\n- Mine changed non-status commands.\n- Mihai's mainly changed \"status\".\n\nNeither series replaces any part of the other.\n\nThere are multiple subtle pre-existing race conditions involved:\n- I fixed some read/lock wrong order races.\n- Mihai fixed a update_index_if_able() race when skipHash=true.\n  (This alone could go to maint.)\n\nMy preference is to keep them separate to bound the mental complexity\nneeded to understand related issues. The actual textual conflict is just\none function name.\n\n-Jun\n\n"}]}