From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Jeff Hostetler via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Jeff Hostetler <jeffhost@microsoft.com>
Subject: Re: [PATCH 1/1] diffcore-rename: speed up register_rename_src
Date: Mon, 10 Jun 2019 14:26:33 +0200 [thread overview]
Message-ID: <20190610122632.GA4012@szeder.dev> (raw)
In-Reply-To: <4ac75dd3635e39f9faa67fb1e88897663e3dc6cd.1560004960.git.gitgitgadget@gmail.com>
On Sat, Jun 08, 2019 at 07:42:42AM -0700, Jeff Hostetler via GitGitGadget wrote:
> From: Jeff Hostetler <jeffhost@microsoft.com>
>
> Teach register_rename_src() to see if new file pair
> can simply be appended to the rename_src[] array before
> performing the binary search to find the proper insertion
> point.
>
> This is a performance optimization. This routine is called
> during run_diff_files in status and the caller is iterating
> over the sorted index, so we should expect to be able to
> append in the normal case. The existing insert logic is
> preserved so we don't have to assume that, but simply take
> advantage of it if possible.
Could you add a command and performance figures to the commit message
to show off the benefits of this patch?
From the description it's clear that it's a performance optimization,
but it's unclear whether it has a noticeable, or at least measurable
effect, or it's "only" a micro-optimization.
I tried something more substantial than a simple 'git status':
# without this patch
$ time perf record -g ./git log --oneline -m --name-only v2.20.0 >/dev/null
[ ... ]
real 2m4.320s
user 2m0.913s
sys 0m2.284s
$ perf report -g none |grep -E '(diffcore_rename|register_rename_src)'
52.40% 0.79% git git [.] diffcore_rename
0.01% 0.01% git git [.] register_rename_src
but it looks like that while more than half of the considerable
runtime is spent detecting renames, the time spent in
register_rename_src(), the function optimized in this patch, is
negligible.
> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> diffcore-rename.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/diffcore-rename.c b/diffcore-rename.c
> index 07bd34b631..5bfc5f6c22 100644
> --- a/diffcore-rename.c
> +++ b/diffcore-rename.c
> @@ -82,6 +82,18 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)
>
> first = 0;
> last = rename_src_nr;
> +
> + if (last > 0) {
> + struct diff_rename_src *src = &(rename_src[last-1]);
> + int cmp = strcmp(one->path, src->p->one->path);
> + if (!cmp)
> + return src;
> + if (cmp > 0) {
> + first = last;
> + goto append_it;
> + }
> + }
> +
> while (last > first) {
> int next = (last + first) >> 1;
> struct diff_rename_src *src = &(rename_src[next]);
> @@ -95,6 +107,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)
> first = next+1;
> }
>
> +append_it:
> /* insert to make it at "first" */
> ALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc);
> rename_src_nr++;
> --
> gitgitgadget
next prev parent reply other threads:[~2019-06-10 12:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-08 14:42 [PATCH 0/1] Optimize run_diff_files()' rename detection Johannes Schindelin via GitGitGadget
2019-06-08 14:42 ` [PATCH 1/1] diffcore-rename: speed up register_rename_src Jeff Hostetler via GitGitGadget
2019-06-08 22:27 ` René Scharfe
2019-06-10 14:23 ` Jeff Hostetler
2019-06-10 12:26 ` SZEDER Gábor [this message]
2019-06-10 14:55 ` Jeff Hostetler
2019-06-10 14:43 ` [PATCH 0/1] Optimize run_diff_files()' rename detection Jeff Hostetler
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=20190610122632.GA4012@szeder.dev \
--to=szeder.dev@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.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.