From: "Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Kristofer Karlsson <krka@spotify.com>,
Derrick Stolee <stolee@gmail.com>,
Kristofer Karlsson <krka@spotify.com>
Subject: [PATCH v3 0/2] commit-reach: use object flags for tips_reachable_from_bases()
Date: Sat, 16 May 2026 15:59:39 +0000 [thread overview]
Message-ID: <pull.2116.v3.git.1778947182.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2116.v2.git.1778922993480.gitgitgadget@gmail.com>
This replaces the O(C*T) linear scan in tips_reachable_from_bases() with an
O(1) flag check using the RESULT object flag.
The function is called by git for-each-ref --merged and git branch/tag
--contains/--no-contains via reach_filter() in ref-filter.c.
Benchmarks on a merge-heavy monorepo (2.3M commits, 10,000 refs):
* for-each-ref --merged HEAD: 6.6s → 1.6s (4.1x)
* for-each-ref --no-merged HEAD: 6.7s → 1.7s (4.0x)
On linux.git with 10,000 synthetic branches at the root commit:
* for-each-ref --merged HEAD: 1.35s → 0.35s (3.9x)
* for-each-ref --no-merged HEAD: 1.82s → 0.31s (5.9x)
v2 of this patch, addressing Jeff King's feedback:
* Replaced the decoration hash with the RESULT object flag (simpler, no
extra data structure, handles duplicate tips naturally)
* Fixed early-termination bug when multiple refs point to the same commit
(the decoration API overwrites on duplicate keys)
* Removed the now-unused index field from struct commit_and_index
* Diff is +11/-12 lines
Kristofer Karlsson (2):
commit-reach: use object flags for tips_reachable_from_bases()
t6600: add tests for duplicate tips in tips_reachable_from_bases()
commit-reach.c | 23 +++++++++++-----------
t/t6600-test-reach.sh | 45 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 12 deletions(-)
base-commit: 59ff4886a579f4bc91e976fe18590b9ae02c7a08
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2116%2Fspkrka%2Ftips-reachable-minimal-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2116/spkrka/tips-reachable-minimal-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/2116
Range-diff vs v2:
1: 7399a12518 = 1: 7399a12518 commit-reach: use object flags for tips_reachable_from_bases()
-: ---------- > 2: 4d11ebb79e t6600: add tests for duplicate tips in tips_reachable_from_bases()
--
gitgitgadget
next prev parent reply other threads:[~2026-05-16 15:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 18:07 [PATCH] commit-reach: use the decoration hash for tips_reachable_from_bases() Kristofer Karlsson via GitGitGadget
2026-05-15 21:14 ` Jeff King
2026-05-16 8:23 ` Kristofer Karlsson
2026-05-16 13:46 ` Derrick Stolee
2026-05-16 9:16 ` [PATCH v2] commit-reach: use object flags " Kristofer Karlsson via GitGitGadget
2026-05-16 15:59 ` Kristofer Karlsson via GitGitGadget [this message]
2026-05-16 15:59 ` [PATCH v3 1/2] " Kristofer Karlsson via GitGitGadget
2026-05-16 15:59 ` [PATCH v3 2/2] t6600: add tests for duplicate tips in tips_reachable_from_bases() Kristofer Karlsson via GitGitGadget
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=pull.2116.v3.git.1778947182.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=krka@spotify.com \
--cc=peff@peff.net \
--cc=stolee@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox