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

Re: [PATCH v2] diff-index: don't queue unchanged filepairs with diff_change()

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 30, 2025, 18:02 UTC
Message-ID
<xmqq5xarcsb8.fsf@gitster.g>
In-Reply-To
<aa28974b-ec73-4562-bfc8-4745ad58b55a@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 17 quoted lines
> Add a new streamlined function for queuing unchanged filepairs and
> use it in show_modified(), which is called by diff_cache() via
> oneway_diff() and do_oneway_diff().  It allocates only a single filespec
> for each filepair and uses it twice with reference counting.  This has a
> measurable effect if there are a lot of them, like in the Linux repo:
>
> Benchmark 1: ./git_v2.52.0 -C ../linux diff --cached --find-copies-harder
>   Time (mean ± σ):      31.8 ms ±   0.2 ms    [User: 24.2 ms, System: 6.3 ms]
>   Range (min … max):    31.5 ms …  32.3 ms    85 runs
>
> Benchmark 2: ./git -C ../linux diff --cached --find-copies-harder
>   Time (mean ± σ):      23.9 ms ±   0.2 ms    [User: 18.1 ms, System: 4.6 ms]
>   Range (min … max):    23.5 ms …  24.4 ms    111 runs
>
> Summary
>   ./git -C ../linux diff --cached --find-copies-harder ran
>     1.33 ± 0.01 times faster than ./git_v2.52.0 -C ../linux diff --cached --find-copies-harder

Nice. Is this technique only applicable to diff-index among the three diff plumbing siblings? I suspect diff-files is an oddball in that on the working tree side we do not necessarily have the blob object names, but it would apply to diff-tree, wouldn't it?

Will queue.  Thanks.
Previous: René ScharfeNext: René Scharfe
Message 2 of 5 in “diff-index: don't queue unchanged filepairs with diff_change()”
  1. diff-index: don't queue unchanged filepairs with diff_change()René Scharfe, Nov 30, 2025
  2. Junio C HamanoNov 30, 2025
  3. René ScharfeDec 2, 2025
  4. René ScharfeDec 2, 2025
  5. René ScharfeDec 3, 2025

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.