git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Utsav Shah <utsav@dropbox.com>
To: git@vger.kernel.org, Kevin Willford <Kevin.Willford@microsoft.com>
Subject: Suboptimal performance of git add -A with untracked cache enabled
Date: Mon, 11 May 2020 12:53:12 -0700	[thread overview]
Message-ID: <CAPYzU3MRTkBH5fAUCydnM8uvuAsv_dAi1B680aB_A5BOU=pyzA@mail.gmail.com> (raw)

I'm running git 2.27 on MacOS catalina on a repo with a size of
roughly ~300k files. Also, I'm using fsmonitor and untracked cache.
Operations like git status are fast as expected and complete under 1s.
But git add -A often takes 10 seconds to complete. The trace output
shows most of the time spent in "read directory" and "diff-files". I'm
mostly interested in solving the slowness in "read directory".

It seems that the untracked cache is skipped by git add -A since the
dir_flags are different between git status and git add
(https://github.com/git/git/blob/master/dir.c#L2671), which leads to
the slowness. In the specific case of add -A, the DIR_COLLECT_IGNORED
flag is set, (https://github.com/git/git/blob/master/builtin/add.c#L543),
which is one reason why the untracked cache is not used. Another is
that git status sets DIR_SHOW_OTHER_DIRECTORIES |
DIR_HIDE_EMPTY_DIRECTORIES
(https://github.com/git/git/blob/master/wt-status.c#L709).

I'm wondering if we can leverage knowledge from fsmonitor to relax
some constraints on using the untracked cache, or skip directory
traversal. In theory, if fsmonitor is aware that there haven't been
any changes to files (tracked or not), it seems that we can skip
opening and iterating over directories.

If anyone has guidance if this is something that can be fixed and has
a recommendation for an approach, I'd love to hear it. I tried working
on a patch, but it seems that the untracked cache is correctly being
skipped for correctness reasons, and I'm not sure if relaxing its
constraints is the right approach.

Thanks

                 reply	other threads:[~2020-05-11 19:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAPYzU3MRTkBH5fAUCydnM8uvuAsv_dAi1B680aB_A5BOU=pyzA@mail.gmail.com' \
    --to=utsav@dropbox.com \
    --cc=Kevin.Willford@microsoft.com \
    --cc=git@vger.kernel.org \
    /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).