git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Emily Shaffer <emilyshaffer@google.com>
To: Jeff Hostetler <git@jeffhostetler.com>
Cc: Derrick Stolee <stolee@gmail.com>, Git List <git@vger.kernel.org>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Jonathan Tan <jonathantanmy@google.com>,
	Kevin Willford <Kevin.Willford@microsoft.com>,
	Derrick Stolee <dstolee@microsoft.com>,
	Jeff Hostetler <jeffhost@microsoft.com>,
	Jeff King <peff@peff.net>
Subject: Re: What to do with fsmonitor-watchman hook and config-based hooks?
Date: Fri, 12 Mar 2021 12:33:00 -0800	[thread overview]
Message-ID: <YEvP/ObHqhaLaSG1@google.com> (raw)
In-Reply-To: <e019cc71-ac39-44a4-0a23-b3b7decec754@jeffhostetler.com>

On Fri, Mar 12, 2021 at 11:51:38AM -0500, Jeff Hostetler wrote:
> I don't think it makes sense to have multiple fsmonitors for a given
> working directory.  They are fairly expensive to operate (listening
> to the kernel for events and building an in-memory database of changed
> files) and I'm not sure how two running concurrently (and listening to
> the same kernel event stream) would come up with different answers.
> 
> The thing about the fsmonitor-watchman or query-watchman hook is that
> it is a bash/perl script that talks to a long-running service daemon.
> The hook script itself is just a proxy to decode the JSON response from
> Watchman and emit it on stdout in a way that the foreground Git command
> expects.  Git cannot directly talk to Watchman because it doesn't
> currently have the plumbing to talk to it on anything other than a fd
> pair that it sets up to give to the hook child.
> 
> So your example of a watcher for NTFS and a separate watcher for ext4
> means you could maybe have two services running, but the foreground
> Git command would only need to spawn a single hook and maybe it would
> decide which service to talk to based upon the filesystem type of the
> working directory.  Or you set the repo-local config for each repo to
> point to a hook script that knew which service to talk to.  Either way
> you only need to invoke one hook.

Thanks, that makes a lot of sense!

> Setting it globally is an option, but fsmonitor is beneficial for large
> repos and working directories.  There is an overhead to having it
> running and talking to it.  (Spawning a hook written in PERL, having
> the hook talk to Watchman via some form of IPC, the hook parsing the mess of
> JSON returned, pumping that data back over stdout to Git, and
> having Git apply the results to the ce_flags.)  All of that has to
> happen *before* Git actually starts to do anything useful.  For small
> repos, all of that overhead costs more than the cost of letting the
> foreground `git status` just lstat() everything.  Of course all of this
> depends on the speed of your filesystem and the size of your working
> directory (and whether you have a sparse-checkout and etc), but there
> are lots of repos that just don't need fsmonitor.
> 
> So yes, I would leave the existing fsmonitor code as is and not try
> to combine it with your current efforts (even if I wasn't working on
> a replacement for the fsmonitor-watchman setup).
> 
> As Stolee mentioned I'm currently working on a builtin fsmonitor
> feature.  It will have a native coded-in-Git-C-code daemon to watch
> the filesystem.  Clients, such as `git status`, will directly talk
> to it via my "Simple IPC" patch series and completely bypass all of
> the hook stuff.
> 
> Long term both fsmonitor solutions can co-exist.  Or we can eventually
> deprecate the hook version.  Given that, I don't see a need to change
> the existing fsmonitor hook code.

Yeah, that seems like the direction everyone agrees with. Thanks very
much for the detailed explanation, that helped me feel sure that doing
nothing is the right approach (how convenient...) :)

I think, then, all that's needed is a patch to the githooks.txt doc 1)
removing the incorrect info about core.fsmonitor's contents needing to
point to a specific name in .git/hooks/ and 2) explaining that because
it uses this special config, it doesn't use the usual hook.*.command
approach.

 - Emily

      parent reply	other threads:[~2021-03-12 20:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 18:42 What to do with fsmonitor-watchman hook and config-based hooks? Emily Shaffer
2021-03-11 19:23 ` Derrick Stolee
2021-03-11 19:36   ` Emily Shaffer
2021-03-12 16:51     ` Jeff Hostetler
2021-03-12 18:33       ` Ævar Arnfjörð Bjarmason
2021-03-12 20:33       ` Emily Shaffer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YEvP/ObHqhaLaSG1@google.com \
    --to=emilyshaffer@google.com \
    --cc=Kevin.Willford@microsoft.com \
    --cc=dstolee@microsoft.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=jeffhost@microsoft.com \
    --cc=jonathantanmy@google.com \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).