From: Junio C Hamano <gitster@pobox.com>
To: Jameson Miller <jameson.miller81@gmail.com>
Cc: bmwill@google.com, git@vger.kernel.org, jamill@microsoft.com,
peff@peff.net, sxlijin@gmail.com
Subject: Re: [PATCH v2] Improve performance of git status --ignored
Date: Tue, 19 Sep 2017 12:27:18 +0900 [thread overview]
Message-ID: <xmqqd16nqsfd.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1505755473-6720-2-git-send-email-jamill@microsoft.com> (Jameson Miller's message of "Mon, 18 Sep 2017 13:24:33 -0400")
Jameson Miller <jameson.miller81@gmail.com> writes:
> Improve the performance of the directory listing logic when it wants to list
> non-empty ignored directories. In order to show non-empty ignored directories,
> the existing logic will recursively iterate through all contents of an ignored
> directory. This change introduces the optimization to stop iterating through
> the contents once it finds the first file.
Wow, such an obviously correct optimization. Very nicely explained, too.
> This can have a significant
> improvement in 'git status --ignored' performance in repositories with a large
> number of files in ignored directories.
>
> For an example of the performance difference on an example repository with
> 196,000 files in 400 ignored directories:
>
> | Command | Time (s) |
> | -------------------------- | --------- |
> | git status | 1.2 |
> | git status --ignored (old) | 3.9 |
> | git status --ignored (new) | 1.4 |
>
> Signed-off-by: Jameson Miller <jamill@microsoft.com>
> ---
I wish all the contributions I have to accept are as nicely done as
this one ;-)
Thanks.
> dir.c | 47 +++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 41 insertions(+), 6 deletions(-)
>
> diff --git a/dir.c b/dir.c
> index 1c55dc3..1d17b80 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -49,7 +49,7 @@ struct cached_dir {
> static enum path_treatment read_directory_recursive(struct dir_struct *dir,
> struct index_state *istate, const char *path, int len,
> struct untracked_cache_dir *untracked,
> - int check_only, const struct pathspec *pathspec);
> + int check_only, int stop_at_first_file, const struct pathspec *pathspec);
We might want to make check_only and stop_at_first_file into a
single "unsigned flags" used as a collection of bits, but we can
wait until we start feeling the urge to add the third boolean
parameter to this function (at which point I'd probably demand a
preliminary clean-up to merge these two into a single flags word
before adding the third one as a new bit in that word).
> @@ -1404,8 +1404,13 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
>
> untracked = lookup_untracked(dir->untracked, untracked,
> dirname + baselen, len - baselen);
> +
> + /*
> + * If this is an excluded directory, then we only need to check if
> + * the directory contains any files.
> + */
> return read_directory_recursive(dir, istate, dirname, len,
> - untracked, 1, pathspec);
> + untracked, 1, exclude, pathspec);
Nicely explained in the in-code comment.
I'd assume that you want your microsoft e-mail address used on the
signed-off-by line appear as the author, so I'll tweak this a bit to
make it so (otherwise, your 81@gmail.com would become the author).
Thanks.
next prev parent reply other threads:[~2017-09-19 3:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 18:49 [PATCH v1 0/1] Teach status to show ignored directories Jameson Miller
2017-08-10 18:49 ` [PATCH v1 1/1] dir: teach " Jameson Miller
2017-08-10 20:03 ` Stefan Beller
2017-08-11 17:48 ` Jameson Miller
2017-08-14 21:05 ` Stefan Beller
2017-08-11 17:39 ` Brandon Williams
2017-08-11 18:29 ` Jameson Miller
2017-09-18 17:24 ` [PATCH v2] Improve performance of git status --ignored Jameson Miller
2017-09-18 17:24 ` Jameson Miller
2017-09-19 3:27 ` Junio C Hamano [this message]
2017-09-19 17:52 ` Brandon Williams
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=xmqqd16nqsfd.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=jameson.miller81@gmail.com \
--cc=jamill@microsoft.com \
--cc=peff@peff.net \
--cc=sxlijin@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.
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.