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

Re: [PATCH 0/2] describe and diff: implement --no-optional-locks

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 10, 2025, 23:04 UTC
Message-ID
<xmqq34fk5vxz.fsf@gitster.g>
In-Reply-To
<bbc8a0ef-737c-44ba-9786-f5456f5ce71b@app.fastmail.com>
"Benjamin Woodruff" <github@benjam.info> writes:
Show 7 quoted lines
>>> The commands at the Porcelain level, like "status" and "diff",
>>> refresh the index for the CORRECTNESS purposes.
>>
>> Right, but "status" supports --no-optional-locks already.
>
> Does this mean the documentation in `git-status` is incorrect? It
> implies that the background refresh is only for performance reasons.

It has to do, and it does, refresh the in-core index for correctness reasons. Writing the result out to the on-disk file for _other_ processes that will use the index later is a performance hack, and may or may not happen (it is up to what repo_update_index_if_able() does).

If we do not care about redundant refreshing these other processes need to do before they start, we do not have to write the resulting in-core index out to the disk.

Writing the in-core index out for other processes has one downside, which is that for correctness it has to be done under lock. We cannot say "we tried to be nice to others by writing the index file out, but we just found out that there is a competing process trying to open/write the index so let's skip writing it and let them do their thing---they are responsible for refreshing the index for their own use". There needs some coordination, i.e. when we start writing the result of our refreshing the index for others, if other processes need to pay attention to that fact and wait for a while before reading the index, then they benefit because they do not have to refresh the index themselves. Even though our programs, by calling hold_lock_file_for_update(), know how to wait for a bit when this happens, not everybody cooperates.

Previous: Benjamin WoodruffNext: Jeff King
Message 10 of 11 in “describe and diff: implement --no-optional-locks”
  1. 0/2 describe and diff: implement --no-optional-locksBenjamin Woodruff via GitGitGadget, Mar 6, 2025
  2. 1/2 describe: implement --no-optional-locksBenjamin Woodruff via GitGitGadget, Mar 6, 2025
  3. 2/2 diff: implement --no-optional-locksBenjamin Woodruff via GitGitGadget, Mar 6, 2025
  4. Junio C HamanoMar 6, 2025
  5. Jeff KingMar 9, 2025
  6. Junio C HamanoMar 10, 2025
  7. Jeff KingMar 10, 2025
  8. Junio C HamanoMar 10, 2025
  9. Benjamin WoodruffMar 10, 2025
  10. Junio C HamanoMar 10, 2025
  11. Jeff KingMar 11, 2025

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.