git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git diff too slow for a file

From
Junio C Hamano <gitster@pobox.com>
Date
May 2, 2010, 15:10 UTC
Message-ID
<7v1vduwd8j.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4BDD7869.10701@lsrfire.ath.cx>
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 16 quoted lines
> 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.
Show 13 quoted lines
> 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.

Previous: René ScharfeNext: René Scharfe
Message 9 of 12 in “git diff too slow for a file”
  1. SungHyun NamMar 29, 2010
  2. René ScharfeApr 17, 2010
  3. Junio C HamanoApr 17, 2010
  4. René ScharfeApr 18, 2010
  5. Junio C HamanoApr 20, 2010
  6. René ScharfeApr 20, 2010
  7. Junio C HamanoApr 21, 2010
  8. René ScharfeMay 2, 2010
  9. Junio C HamanoMay 2, 2010
  10. René ScharfeMay 4, 2010
  11. Junio C HamanoMay 4, 2010
  12. SungHyun NamApr 19, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.