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
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Aug 24, 2012, 11:42 UTC
Message-ID
<CACsJy8DJLmNWDNhGczk_0qDngHxDgQMh7zskxJXTqLGQ8gwugw@mail.gmail.com>
In-Reply-To
<878vd5k7uu.fsf@thomas.inf.ethz.ch>
On Thu, Aug 23, 2012 at 9:20 PM, Thomas Rast <trast@student.ethz.ch> wrote:
Show 27 quoted lines
> At the very least it should be possible to change in_merge_bases() to
> not do any of the post-filtering; perhaps like the patch below.  It
> passes the test suite.  The whole "merge bases of A and a list of Bs"
> thing is blowing my overheated mind, though, so I'm not able to convince
> myself that it is correct in all cases.
>
> diff --git i/commit.c w/commit.c
> index 65a8485..70427ab 100644
> --- i/commit.c
> +++ w/commit.c
> @@ -837,10 +837,13 @@ int in_merge_bases(struct commit *commit, struct commit **reference, int num)
>         struct commit_list *bases, *b;
>         int ret = 0;
>
> -       if (num == 1)
> -               bases = get_merge_bases(commit, *reference, 1);
> -       else
> +       if (num != 1)
>                 die("not yet");
> +
> +       bases = merge_bases_many(commit, 1, reference);
> +       clear_commit_marks(commit, all_flags);
> +       clear_commit_marks(*reference, all_flags);
> +
>         for (b = bases; b; b = b->next) {
>                 if (!hashcmp(commit->object.sha1, b->item->object.sha1)) {
>                         ret = 1;

Without looking into detail (as I'm not familiar with this code), this patch does not help much. Without the patch:

$ time ./git merge-base a4f2db3 b95a282 ed36e5bd41f7192e42e9b4c573875a343a9daf48

real 0m19.988s user 0m19.797s sys 0m0.082s

With the patch:

$ time ./git merge-base a4f2db3 b95a282 ed36e5bd41f7192e42e9b4c573875a343a9daf48

real 0m19.560s user 0m19.448s sys 0m0.037s

-- 
Duy
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 12 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.