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

Re: [PATCH 1/1] builtin/receive-pack: avoid spinning no-op sideband async threads

From
Jeff King <peff@peff.net>
Date
Mar 3, 2026, 13:28 UTC
Message-ID
<20260303132855.GA748945@coredump.intra.peff.net>
In-Reply-To
<20260302191704.1814567-2-adrian.ratiu@collabora.com>
On Mon, Mar 02, 2026 at 09:17:04PM +0200, Adrian Ratiu wrote:
> It is important to call the hook_exists() API provided by hook.[ch]
> because it covers both config-defined hooks and the "traditional"
> hooks from the hookdir. find_hook() only covers the hookdir hooks.

Ah, OK. Traditionally hook_exists() was just a thin wrapper over find_hook(), but it looks like that changed in your series. But either way, it much more clearly expresses the intent to use hook_exists().

So this obviously looks good, but just some random thoughts below.
Show 6 quoted lines
> @@ -934,6 +934,9 @@ static int run_receive_hook(struct command *commands,
>  	int saved_stderr = -1;
>  	int ret;
>  
> +	if (!hook_exists(the_repository, hook_name))
> +		return 0;

It is a little inelegant that we have to look up the hook data separately ourselves here, and then it will be done again in run_hooks_opt(). But I don't think there is an easy way to reorganize it, short of something like:

  struct hook myhook = HOOK_INIT;
  load_hooks(&myhook, hook_name);
  if (myhook.nr)
	return 0; /* no hooks of this type */
  ...other prep work...
  run_hooks_opt(repo, &myhook, &opt);

I doubt that is worth it, as the lookup process should not be too expensive. It looks like we cache the config parts of the lookup already. We call access() to find the traditional hooks on each lookup, but that is also true of the code before your series.

It would not matter at all for pre-receive, for example, but for something like update, I guess we are doing a bunch of pointless access() calls that could be cached. But again, not new in your series, and nobody has really noticed. So we can either treat it as an optimization for later, or just leave it be forever.

-Peff
Previous: Adrian Ratiu
Message 7 of 7 in “Fix update hook perf regression in next”
  1. 0/1 Fix update hook perf regression in nextAdrian Ratiu, Mar 2, 2026
  2. 1/1 builtin/receive-pack: avoid spinning no-op sideband async threadsAdrian Ratiu, Mar 2, 2026
  3. Junio C HamanoMar 2, 2026
  4. Adrian RatiuMar 3, 2026
  5. Patrick SteinhardtMar 3, 2026
  6. Adrian RatiuMar 3, 2026
  7. Jeff KingMar 3, 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.