All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Maik Riechert via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Josip Sokcevic <sokcevic@google.com>,
	 Maik Riechert <letmaik@outlook.com>
Subject: Re: [PATCH v2] diff-lib: skip leading path check for fsmonitor-valid entries
Date: Thu, 19 Nov 2026 14:06:33 -0800	[thread overview]
Message-ID: <xmqqv75sv5li.fsf@gitster.g> (raw)
In-Reply-To: <pull.2318.v2.git.1795067037014.gitgitgadget@gmail.com> (Maik Riechert via GitGitGadget's message of "Thu, 19 Nov 2026 05:43:56 +0000")

"Maik Riechert via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Maik Riechert <letmaik@outlook.com>
>
> Since 4f3d6d0261 (fsmonitor: skip lstat deletion check during git
> diff-index, 2021-03-17), check_removed() does not lstat() entries
> that fsmonitor says are unchanged. But it still calls
> has_symlink_leading_path() for them, which lstat()s the directories
> leading up to each path.
>
> That check is there to notice a leading directory that was replaced
> by a symlink. fsmonitor would have reported such a change, and
> refresh_fsmonitor() would have cleared CE_FSMONITOR_VALID for every
> entry below it, so we would not get here. preload_index() already
> trusts the flag this way and skips these entries altogether.
>
> The S_ISDIR() check that follows cannot trigger either: the mode
> comes from the index, and gitlinks are never marked valid.

This is slightly misleading.  S_IFGITLINK is given S_IFDIR | 0755
by st_mode_from_ce() that is called by fake_lstat(), so S_ISDIR()
check *does* trigger.  We have an extra S_ISGITLINK() guard in
there, preventing us from calling repo_resolve_gitlink_ref().

It does not change the conclusion, though.

> So return as soon as fake_lstat() has filled in the stat data.
>
> The first new test checks the shortcut itself by replacing a parent
> directory with a symlink without telling fsmonitor. The other two make
> sure we still notice when fsmonitor does report that directory, with
> and without a trailing slash, since nothing else checks for it now.
>
> On Linux, with 100,000 files (ten per directory), a hook that
> reports nothing and a warm cache, "git diff HEAD" goes from 57ms to
> 26ms.
>
> Signed-off-by: Maik Riechert <letmaik@outlook.com>
> ---

Will queue.  Thanks.

      reply	other threads:[~2026-11-19 22:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 18:22 [PATCH] diff-lib: skip leading path check for fsmonitor-valid entries Maik Riechert via GitGitGadget
2026-11-18 19:01 ` Junio C Hamano
2026-11-19  5:43 ` [PATCH v2] " Maik Riechert via GitGitGadget
2026-11-19 22:06   ` Junio C Hamano [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

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

  git send-email \
    --in-reply-to=xmqqv75sv5li.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=letmaik@outlook.com \
    --cc=sokcevic@google.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.