From: Derrick Stolee <stolee@gmail.com>
To: Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Cc: Derrick Stolee <dstolee@microsoft.com>,
Jonathan Tan <jonathantanmy@google.com>,
Taylor Blau <me@ttaylorr.com>, Junio C Hamano <gitster@pobox.com>,
Jeff King <peff@peff.net>, Karsten Blees <blees@dcon.de>,
Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH 1/2] diffcore-rename: no point trying to find a match better than exact
Date: Wed, 3 Feb 2021 06:44:50 -0500 [thread overview]
Message-ID: <515f55bd-90e2-9a7f-0973-501c9351969e@gmail.com> (raw)
In-Reply-To: <3e69857f37e12540f7986245b99916b68702217a.1612331345.git.gitgitgadget@gmail.com>
On 2/3/2021 12:49 AM, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
>
> diffcore_rename() had some code to avoid having destination paths that
> already had an exact rename detected from being re-checked for other
> renames. Source paths, however, were re-checked because we wanted to
> allow the possibility of detecting copies. But if copy detection isn't
> turned on, then this merely amounts to attempting to find a
> better-than-exact match, which naturally ends up being an expensive
> no-op. In particular, copy detection is never turned on by the merge
> machinery.
...
> + num_sources = rename_src_nr;
> + if (detect_rename != DIFF_DETECT_COPY)
> + num_sources -= rename_count;
Ok, delete the renamed files from the sources. Using a new variable
because rename_src_nr is actually a static global to diffcore-rename.c,
describing the number of entries in the rename_src table. This is
scary, but I think your new local is a good way to change the local
logic of this method without adjusting that global.
>
> /* All done? */
> - if (!num_destinations)
> + if (!num_destinations || !num_sources)
> goto cleanup;
And add an extra quit condition which is very possible to hit.
Is it only hit when every "delete" is actually a rename?
> - switch (too_many_rename_candidates(num_destinations, rename_src_nr,
> + switch (too_many_rename_candidates(num_destinations, num_sources,
> options)) {
This is all about checking if we need to skip inexact renames. Makes
sense to use the new number.
> + if (one->rename_used &&
> + detect_rename != DIFF_DETECT_COPY)
> + continue;
> +
Have we "consumed" this input? Skip over it. Good. And this is inside
a double-loop:
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
...
for (j = 0; j < rename_src_nr; j++) {
Keeping rename_src_nr in the inner loop makes sense, but this new
'continue;' gives most of the speedup, I imagine.
This is a nice speedup for such a simple optimization.
Thanks,
-Stolee
next prev parent reply other threads:[~2021-02-03 11:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-03 5:49 [PATCH 0/2] Optimization batch 6: make full use of exact renames Elijah Newren via GitGitGadget
2021-02-03 5:49 ` [PATCH 1/2] diffcore-rename: no point trying to find a match better than exact Elijah Newren via GitGitGadget
2021-02-03 11:44 ` Derrick Stolee [this message]
2021-02-03 16:31 ` Elijah Newren
2021-02-03 18:46 ` Junio C Hamano
2021-02-03 19:10 ` Elijah Newren
2021-02-03 5:49 ` [PATCH 2/2] diffcore-rename: filter rename_src list when possible Elijah Newren via GitGitGadget
[not found] ` <13feb106-c3a7-a26d-0e6e-013aa45c58d4@gmail.com>
2021-02-03 17:12 ` Elijah Newren
2021-02-03 19:12 ` Junio C Hamano
2021-02-03 19:19 ` Elijah Newren
2021-02-03 20:03 ` [PATCH v2 0/2] Optimization batch 6: make full use of exact renames Elijah Newren via GitGitGadget
2021-02-03 20:03 ` [PATCH v2 1/2] diffcore-rename: no point trying to find a match better than exact Elijah Newren via GitGitGadget
2021-02-03 20:03 ` [PATCH v2 2/2] diffcore-rename: filter rename_src list when possible Elijah Newren via GitGitGadget
2021-02-13 1:04 ` Junio C Hamano
2021-02-13 4:24 ` Elijah Newren
2021-02-13 1:06 ` Junio C Hamano
2021-02-13 4:43 ` Elijah Newren
2021-02-03 21:56 ` [PATCH v2 0/2] Optimization batch 6: make full use of exact renames Junio C Hamano
2021-02-03 23:06 ` Elijah Newren
2021-02-03 23:26 ` Junio C Hamano
2021-02-03 23:36 ` Jeff King
2021-02-04 0:05 ` Elijah Newren
2021-02-14 7:34 ` [PATCH v3 " Elijah Newren via GitGitGadget
2021-02-14 7:35 ` [PATCH v3 1/2] diffcore-rename: no point trying to find a match better than exact Elijah Newren via GitGitGadget
2021-02-14 7:35 ` [PATCH v3 2/2] diffcore-rename: filter rename_src list when possible Elijah Newren via GitGitGadget
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=515f55bd-90e2-9a7f-0973-501c9351969e@gmail.com \
--to=stolee@gmail.com \
--cc=blees@dcon.de \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=jonathantanmy@google.com \
--cc=me@ttaylorr.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
/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).