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

Re: in_merge_bases() is too expensive for recent "pu" update

From
Thomas Rast <trast@student.ethz.ch>
Date
Aug 24, 2012, 09:32 UTC
Message-ID
<87sjbceiu9.fsf@thomas.inf.ethz.ch>
In-Reply-To
<7vy5l52ueg.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> As a corollary, the "is pu@{0} a fast-forward of pu@{1}?" check does
> not need merge base computation at all.  The only thing it needs to
> do is to prove pu@{1} is reachable from pu@{0}, and that can be done
> the same way in which '1' can be proved unreachable from '2' in the
> post processing phase as described above, i.e. it needs only the
> first phase of running merge_bases_many() without postprocessing.
Well, yeah, you snipped this part from my original post :-)

} Even if this turns out to be flawed, we should also identify uses of } in_merge_bases() where the real question was is_descendant_of() [I } somewhat suspect that's all of them], and then replace is_descendant_of } with a much cheaper lookup. This can be as simple as propagating a mark } from the candidate until it either goes beyond all possible ancestors, } or hits one of them.

As far as the "real question" goes, I'm purely guessing here -- it is entirely possible that a bunch of the in_merge_bases() checks really do need the pruned set of merge bases. But this particular check, and I suspect a bunch of others, does not.

Then there's the next bit:

} By the way, the internal slowness of git-merge-base also affects the } A...B syntax. For example, } } git rev-list --left-right --count @{upstream}... } } is used by the __git_ps1 code to determine the prompt display, which } just got very slow for me today. Again, it should be easy to figure out } the boundary of the symmetric difference simply by propagating two } marks. I do not think that the result of A...B actually depends on } figuring out exactly what the merge bases are, simply excluding *any* } candidate without pruning is enough.

Apart from __git_ps1, this is also used by git-status, git-checkout and 'git branch -v' to show "your branch is N behind and M ahead". Again it's a bit of a hunch, but I think figuring out the symmetric difference is a simple matter of propagating two marks and including only commits that ended up having exactly one of them. At least the counting case should be easy, rev-list is slightly harder to fix.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 16 in “in_merge_bases() is too expensive for recent "pu" update”
  1. Nguyen Thai Ngoc DuyAug 23, 2012
  2. Thomas RastAug 23, 2012
  3. Junio C HamanoAug 23, 2012
  4. Junio C HamanoAug 23, 2012
  5. Junio C HamanoAug 23, 2012
  6. Thomas RastAug 24, 2012
  7. Junio C HamanoAug 24, 2012
  8. Thomas RastAug 24, 2012
  9. Jeff KingAug 24, 2012
  10. Junio C HamanoAug 24, 2012
  11. Junio C HamanoAug 24, 2012
  12. Nguyen Thai Ngoc DuyAug 24, 2012
  13. Nguyen Thai Ngoc DuyAug 24, 2012
  14. Junio C HamanoAug 28, 2012
  15. Thomas RastAug 28, 2012
  16. Junio C HamanoAug 28, 2012

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.