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

Re: [PATCH] fsmonitor: only enable it in non-bare repositories

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 3, 2021, 17:56 UTC
Message-ID
<87k0oex1yi.fsf@evledraar.gmail.com>
In-Reply-To
<810dc60c-3730-b5f3-34f6-5cc2ddc9942a@jeffhostetler.com>
On Mon, May 03 2021, Jeff Hostetler wrote:
Show 30 quoted lines
> On 5/3/21 9:58 AM, Ævar Arnfjörð Bjarmason wrote:
>> On Thu, Apr 29 2021, Johannes Schindelin via GitGitGadget wrote:
>> 
>>> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>>>
>>> The entire point of the FSMonitor is to monitor the worktree changes in
>>> a more efficient manner than `lstat()`ing all worktree files every time
>>> we refresh the index.
>>>
>>> But if there is no worktree, FSMonitor has nothing to monitor.
>>>
>>> So let's ignore if an FSMonitor is configured (e.g. in `~/.gitconfig`)
>>> and we're running in a repository without worktree.
>>>
>>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>>> ---
> ...
>>>
>>> base-commit: 14d50074ff19e68e7a8d718b22d138882087bbc9
>> This is surely a correct fix for now, but wouldn't it in the future
>> also
>> be useful to run it in bare repositories e.g. to be able cache lookups
>> for non-existing loose objects?
>> 
>
> No, the FSMonitor feature only expects data for paths within the
> working directory.  (And is independent of whether the FS change
> data is provided by my fsmonitor--daemon or provided by a hook-based
> provider, such as Watchman.)  The FSMonitor feature uses that data to
> shortcut scans of the working directory.

Indeed, hence "in the future". I'm not suggesting that it'll do anything useful by watching anything in the .git directory now, but that it might be an interesting thing to explore.

> There is no interaction with the contents of the .git/objects
> directory and I'm not sure how that would work.

We'd watch .git/objects and .git/objects/{aa..ff}, then when about to check for a loose object we'd avoid hitting the FS.

I don't know how useful that is post-61c7711cfea (sha1-file: use loose object cache for quick existence check, 2018-11-12), but e.g. on NFS this sort of thing still mattered. I had a "bigger hammer" approach with [1] that ran (and still does, I believe) on a big corporate installation.

More generally, if you strace .git access during repo operations you'll find we're doing all sorts of existence checks etc. all the time. Loose objects, refs, seeing what packs there are (better with the MIDX, but do we still fall back?) etc. If we had up-to-date inotify/fsmonitor info we could ask the daemon about it.

1. https://lore.kernel.org/git/20181028225023.26427-5-avarab@gmail.com/
Previous: Jeff HostetlerNext: Jeff Hostetler
Message 6 of 7 in “fsmonitor: only enable it in non-bare repositories”
  1. fsmonitor: only enable it in non-bare repositoriesJohannes Schindelin via GitGitGadget, Apr 29, 2021
  2. Junio C HamanoApr 30, 2021
  3. fsmonitor: only enable it in non-bare repositoriesJohannes Schindelin via GitGitGadget, May 3, 2021
  4. Ævar Arnfjörð BjarmasonMay 3, 2021
  5. Jeff HostetlerMay 3, 2021
  6. Ævar Arnfjörð BjarmasonMay 3, 2021
  7. Jeff HostetlerMay 11, 2021

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.