From: Junio C Hamano <gitster@pobox.com>
To: Meet Soni <meetsoni3017@gmail.com>
Cc: git@vger.kernel.org, "Jeff King" <peff@peff.net>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Patrick Steinhardt" <ps@pks.im>,
"Calvin Wan" <calvinwan@google.com>,
"Elijah Newren" <newren@gmail.com>
Subject: Re: [GSoC][RFC PATCH] show-branch: use commit-slab for flag storage
Date: Tue, 18 Feb 2025 10:40:21 -0800 [thread overview]
Message-ID: <xmqqseobksfe.fsf@gitster.g> (raw)
In-Reply-To: <20250217055049.9217-1-meetsoni3017@gmail.com> (Meet Soni's message of "Mon, 17 Feb 2025 11:20:49 +0530")
Meet Soni <meetsoni3017@gmail.com> writes:
> Replace direct accesses to commit->object.flags with the commit-slab
> mechanism. Introduce `get_commit_flags()` and `set_commit_flags()` to
> retrieve and update flags, respectively, and include `revision.h` so that
> the canonical UNINTERESTING definition is used.
>
> Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
Ohhhh. I thought people somehow have "refactored" the commit
traversal code here to share more with the machinery used by the
"log" family of commands, but the change in this patch being
contained within the single "show-branch" file indicates that it is
not the case, which is good ;-)
And the MAX_REVS limitation has been with us from the very beginning
of the "show-branch" command. Lifting it is very good ;-) ;-).
> ---
> I'm not entirely sure what the TODO comment meant by storing a pointer to
> the "ref name" directly, so I've assumed that the intent was to store
> flags (of type int) directly in the commit-slab instead of commit->object.
It has been forever since I looked at the code around here the last
time, but I suspect that it meant the final mapping the code makes
at the output phase from the bit position in the flags bits to which
reference the bit (i.e. "I am reachable from that ref") could be
omitted if we make the slab entry a set of (interned) refnames.
But I think using a slab whose element is still a bag of bits that
is wider than object.flags word is is the most straight-forward way
to lift MAX_REVS limitation. If we can leave everything else
unchanged, that would be great.
> I've tested these changes using:
> - test suite -- they passed.
> - github ci result -- https://github.com/inosmeet/git/actions/runs/13355488433
New tests that traverse from more than historical MAX_REVS would be
the most interesting.
It is not exactly surprising if the existing tests do not exercise
such a case (even though it probably should have been checking that
the command refused to accept more than MAX_REVS refs to prevent it
from producing garbage results).
If there were such a test to illustrate what happens when too many
refs are given, we can demonstrate how the behaviour changes, for
the better, with this change ;-)
However ...
> +static int get_commit_flags(struct commit *commit)
> +{
> + int *result = commit_flags_peek(&commit_flags, commit);
> + return result ? *result : 0;
> +}
> +
> +static void set_commit_flags(struct commit *commit, int flags)
> +{
> + *commit_flags_at(&commit_flags, commit) = flags;
> +}
... it does not make much sense to use the slab mechanism if we are
still limited to bitsizeof(type(flags)). If your "int" is 32 bit,
and the command line fed 100 revs, we'd want a flags parameter that
can house at least 100 bits passed into the "set" function, and
yields the result that can hold at least 100 bits from the "get"
function. I'd expect that the interface would be more like
static int get_commit_flags(struct commit *commit, unsigned flags[]);
static int set_commit_flags(struct commit *commit, unsigned flags[]);
with a file-scope static variable signaling how many bits we are
dealing with (allowing these functions to infer how many words
flags[] array has), and the return values from these helpers to
indicate success (with 0) and failure (with a negative value). On a
32-bit platform, you'd need at least 4 words in flags[] array to
deal with 100 revs. On a 64-bit box, 2 words would be sufficient.
I would imagine that we would need two more helpers
static int set_flag_bit(unsigned flags[], unsigned n);
static int get_flag_bit(unsigned flags[], unsigned n);
to query the n-th bit in a set of bits stored in flags[] array.
Thanks.
next prev parent reply other threads:[~2025-02-18 18:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 5:50 [GSoC][RFC PATCH] show-branch: use commit-slab for flag storage Meet Soni
2025-02-18 18:40 ` Junio C Hamano [this message]
2025-02-21 6:32 ` Jeff King
2025-02-21 17:15 ` Junio C Hamano
2025-02-25 1:17 ` Jeff King
2025-03-02 12:56 ` Ghanshyam Thakkar
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=xmqqseobksfe.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=calvinwan@google.com \
--cc=git@vger.kernel.org \
--cc=meetsoni3017@gmail.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).