From: Junio C Hamano <gitster@pobox.com>
To: "Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Kristofer Karlsson <krka@spotify.com>
Subject: Re: [PATCH v4 2/2] commit-reach: early exit paint_down_to_common for single merge-base
Date: Tue, 12 May 2026 09:40:42 +0900 [thread overview]
Message-ID: <xmqqbjelqx2t.fsf@gitster.g> (raw)
In-Reply-To: <19f1605067e26c8e393c6c2e341844bcb3dc1b41.1778504352.git.gitgitgadget@gmail.com> (Kristofer Karlsson via GitGitGadget's message of "Mon, 11 May 2026 12:59:12 +0000")
"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Kristofer Karlsson <krka@spotify.com>
>
> Commits not in the commit-graph get GENERATION_NUMBER_INFINITY and
> sort to the top of the priority queue. After those, commits with
> finite generation numbers are popped in non-increasing order.
> When MERGE_BASE_FIND_ALL is not set the first doubly-painted commit
> with a finite generation is therefore a best merge-base: no commit
> still in the queue can be a descendant of it. Skip the expensive
> STALE drain in this case.
>
> Add MERGE_BASE_FIND_ALL to the merge_base_flags enum. Callers that
> need every merge-base (repo_get_merge_bases_many, repo_get_merge_bases,
> repo_in_merge_bases_many, remove_redundant_no_gen) pass the flag to
> preserve existing behavior. git merge-base (without --all) passes 0,
> triggering the early exit.
>
> On a 2.2M-commit merge-heavy monorepo with commit-graph:
>
> HEAD vs ~500: 5,229ms -> 24ms
> HEAD vs ~1000: 4,214ms -> 39ms
> HEAD vs ~5000: 3,799ms -> 46ms
> HEAD vs ~10000: 3,827ms -> 61ms
>
> Signed-off-by: Kristofer Karlsson <krka@spotify.com>
> ---
> builtin/merge-base.c | 3 ++-
> commit-reach.c | 19 +++++++++++++++----
> commit-reach.h | 7 ++++++-
> t/t6600-test-reach.sh | 40 ++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 63 insertions(+), 6 deletions(-)
Very nicely done and well described.
> diff --git a/builtin/merge-base.c b/builtin/merge-base.c
> index 9b50b4660e..a87011c6cd 100644
> --- a/builtin/merge-base.c
> +++ b/builtin/merge-base.c
> @@ -11,11 +11,12 @@
>
> static int show_merge_base(struct commit **rev, size_t rev_nr, int show_all)
> {
> + enum merge_base_flags flags = show_all ? MERGE_BASE_FIND_ALL : 0;
Curious that only this variable, among 6 that this two-patch series
introduces for the type, is called "flags" while all others are
called "mb_flags". No need to change it; the comment is mostly to
show I did read the two patches with reasonable attention to the
detail ;-).
Will queue. Thanks.
next prev parent reply other threads:[~2026-05-12 0:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 15:07 [PATCH] commit-reach: early exit paint_down_to_common for single merge-base Kristofer Karlsson via GitGitGadget
2026-05-11 2:08 ` Junio C Hamano
2026-05-11 6:19 ` [PATCH v2] " Kristofer Karlsson via GitGitGadget
2026-05-11 7:22 ` Patrick Steinhardt
2026-05-11 11:22 ` [PATCH v3] " Kristofer Karlsson via GitGitGadget
2026-05-11 12:04 ` Patrick Steinhardt
2026-05-11 12:59 ` [PATCH v4 0/2] [RFC] commit-reach: skip STALE drain when only one merge-base needed Kristofer Karlsson via GitGitGadget
2026-05-11 12:59 ` [PATCH v4 1/2] commit-reach: introduce merge_base_flags enum Kristofer Karlsson via GitGitGadget
2026-05-11 12:59 ` [PATCH v4 2/2] commit-reach: early exit paint_down_to_common for single merge-base Kristofer Karlsson via GitGitGadget
2026-05-12 0:40 ` Junio C Hamano [this message]
2026-05-12 5:16 ` Kristofer Karlsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqbjelqx2t.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=krka@spotify.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.