git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: SungHyun Nam <goweol@gmail.com>, git@vger.kernel.org
Subject: Re: git diff too slow for a file
Date: Sun, 02 May 2010 08:10:52 -0700	[thread overview]
Message-ID: <7v1vduwd8j.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4BDD7869.10701@lsrfire.ath.cx> ("René Scharfe"'s message of "Sun\, 02 May 2010 15\:04\:41 +0200")

René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:

> Ever since the xdiff library had been introduced to git, all its callers
> have used the flag XDF_NEED_MINIMAL.  It makes sure that the smallest
> possible diff is produced, but that takes quite some time if there are
> lots of differences that can be expressed in multiple ways.
>
> This flag makes a difference for only 0.1% of the non-merge commits in
> the git repo of Linux, both in terms of diff size and execution time.
> The patches there are mostly nice and small.
>
> SungHyun Nam however reported a case in a different repo where a diff
> took more than 20 times longer to generate with XDF_NEED_MINIMAL than
> without.  Rebasing became really slow.
>
> This patch removes this flag from all callers.  The default of xdiff is
> saner because it has minimal to no impact in the normal case of small
> diffs and doesn't incur that much of a speed penalty for large ones.

Thanks, will queue.

> diff --git a/merge-file.c b/merge-file.c
> index c336c93..db4d0d5 100644
> --- a/merge-file.c
> +++ b/merge-file.c
> @@ -66,7 +66,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
>  	xdemitcb_t ecb;
>  
>  	memset(&xpp, 0, sizeof(xpp));
> -	xpp.flags = XDF_NEED_MINIMAL;
> +	xpp.flags = 0;
>  	memset(&xecfg, 0, sizeof(xecfg));
>  	xecfg.ctxlen = 3;
>  	xecfg.flags = XDL_EMIT_COMMON;

When I wrote the message you are responding to, I tried to decide which is
better, to replace the assigned value like your patch does, or to remove
the assignment altogether as we have memset(&xpp, 0, sizeof(xpp)).  And I
was somewhat torn.

While it expresses what the patch wants to do a lot clearer (and it also
marks the places the "later patch" needs to touch), the resulting code
becomes slightly harder to read, because future readers of the code are
left with an obvious "why do we assign 0 after clearing the whole thing?
is there anything subtle going on?" unanswered.

  reply	other threads:[~2010-05-02 15:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-29  1:42 git diff too slow for a file SungHyun Nam
2010-04-17 15:52 ` René Scharfe
2010-04-17 17:10   ` Junio C Hamano
2010-04-18 18:01     ` René Scharfe
2010-04-20  7:40       ` Junio C Hamano
2010-04-20 21:15         ` René Scharfe
2010-04-21  2:49           ` Junio C Hamano
2010-05-02 13:04         ` René Scharfe
2010-05-02 15:10           ` Junio C Hamano [this message]
2010-05-04 20:16             ` René Scharfe
2010-05-04 22:56               ` Junio C Hamano
2010-04-19  0:43   ` SungHyun Nam

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=7v1vduwd8j.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=goweol@gmail.com \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /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 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 NNTP newsgroup(s).