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
Junio C Hamano <gitster@pobox.com>
Date
Aug 28, 2012, 16:03 UTC
Message-ID
<7vehmr57ia.fsf@alter.siamese.dyndns.org>
In-Reply-To
<877gsjmo3a.fsf@thomas.inf.ethz.ch>
Thomas Rast <trast@inf.ethz.ch> writes:
> I'm also mildly surprised that it ended up being correct, albeit with
> some extra work from you :-)

I actually am not all that surprised. It just shows that the original code was layered in more or less the right way. At the the bottom layer we would want a way to paint graph down to common ancestors cheaply, and then on top we want to have a way to filter out the redundant ones. It is a different story that the implementation of individual layers may still have rooms for improvements (just like the last patch in my series showed for the upper layer where we used to do N * (N-1) when we only needed N).

I have a suspicion that the merge_bases_many() at the bottom layer could be built on an even cheaper API. This caller you added does not need "bases" list returned; it only wants to see that ancestors of "commit" and "reference" down to their common ancestors are painted in two colors PARENT1 and PARENT2. Instead of iterating over the returned candidate list, we might be able to do

	common = PARENT1 | PARENT2;
	paint_ancestors(commit, 1, reference);
        commit_is_common = ((commit->object.flags & common) == common);
        clear_commit_marks(commit, all_flags);
        clear_commit_marks(*reference, all_flags);

where paint_ancestors() just paints but does not accumlate to return a commit_list. Note that paint_ancestors() need to always paint its arguments (merge_bases_many() has an early special case to return a list that only has "commit" when it appears in "reference" without painting anything, and the callers like get_merge_bases_many() know this to avoid calling clear_commit_marks()) if we are to go in this direction, so it is unclear if it will be overall gain.

Previous: Thomas Rast
Message 16 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.