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

Re: [PATCH] commit-reach: fix sorting commits by generation

From
Derrick Stolee <stolee@gmail.com>
Date
Oct 24, 2018, 13:19 UTC
Message-ID
<e2e1bfd8-bb43-0567-0eb7-770ae16da7e2@gmail.com>
In-Reply-To
<20181023203237.GF4883@hank.intra.tgummerer.com>
On 10/23/2018 4:32 PM, Thomas Gummerer wrote:
Show 18 quoted lines
> On 10/22, René Scharfe wrote:
>> Am 22.10.2018 um 23:10 schrieb Thomas Gummerer:
>>
>> Anyway, your implied question was discussed back then.  Derrick wrote:
>>
>>     The reason to sort is to hopefully minimize the amount we walk by
>>     exploring the "lower" commits first. This is a performance-only thing,
>>     not a correctness issue (which is why the bug exists). Even then, it is
>>     just a heuristic.
> Thanks for pointing that out!
>
>> Does b6723e4671 in pu (commit-reach: fix first-parent heuristic) change
>> that picture?  Did a quick test and found no performance difference with
>> and without the fix on top, i.e. proper sorting didn't seem to matter.
> I just gave 'test-tool reach can_all_from_reach' a try and got the
> same results, with or without the fix the times are very similar.  I
> haven't had time to follow the commit-graph series though, so I'm not
> sure I used it correctly.

Thanks for your attention here. I've been thinking a lot about this heuristic and have concluded the following two things are true:

(1) When we return 1, the order that we explore the 'from' commits does not change the explored set of commits.

(2) When we return 0, the order that we explore the 'to' commits will change the explored set, but it is difficult to say that the heuristic helps more than it hurts.

Item (1) is contrary to what I had thought when I first created the heuristic.

The details are tricky, but essentially each DFS starting at a 'from' commit may be short-circuited due to a prior walk, but swapping the order of those two 'from' commits would lead to the same set of commits to be explored (with the short-circuit happening in the other commit). The only change is that we can terminate early if we fully explore a 'from' commit and do not find a commit marked with 'with_flag'. In this sense, it would be best to explore the commits that are "closest" to the generation number cutoff first, as we can maybe find a negative answer earlier in the search.

In this sense, we could remove the sort entirely and probably not have much performance hit. But since the set of 'from' commits is probably much smaller than the set of commits to explore, the sort is likely inexpensive.

In conclusion: I cannot say that this sort is super-important. As for the potential benefits in (2), I'll leave that to people who run git as a server who may have telemetry around fetch negotiation. How often do we actually say we need more rounds of negotiation? What kinds of data shapes matter there?

Thanks, -Stolee

Previous: Thomas Gummerer
Message 4 of 4 in “commit-reach: fix sorting commits by generation”
  1. commit-reach: fix sorting commits by generationThomas Gummerer, Oct 22, 2018
  2. René ScharfeOct 22, 2018
  3. Thomas GummererOct 23, 2018
  4. Derrick StoleeOct 24, 2018

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.