From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/3] commit-slab: introduce a macro to define a slab for new type
Date: Sun, 14 Apr 2013 18:32:42 -0700 [thread overview]
Message-ID: <7vppxw4lz9.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130414184121.GA1621@sigill.intra.peff.net> (Jeff King's message of "Sun, 14 Apr 2013 14:41:21 -0400")
Jeff King <peff@peff.net> writes:
> On Sat, Apr 13, 2013 at 11:04:49PM -0700, Junio C Hamano wrote:
>
>> Suppose you want to give one bit per existing ref and paint commits
>> down to find which refs are descendants of each commit. You find
>> that you have 320 refs only at runtime.
>>
>> The code can declare a commit slab "struct flagbits"
>>
>> define_commit_slab(flagbits, unsigned char);
>> struct flagbits flags;
>>
>> and initialize it by:
>>
>> nrefs = ... count number of refs that returns say 320 ...
>> init_flagbits_with_stride(&flags, (nrefs + 7) / 8);
>>
>> so that
>>
>> unsigned char *fp = flagbits_at(&flags, commit);
>>
>> will return a pointer pointing at an array of 40 "unsigned char"s
>> associated with the commit.
>
> Thanks, I was thinking originally that we would want to break it down
> into "unsigned long" or something, but there is probably no real
> performance advantage to doing that over bytes.
The 320 came from writing "an array of 5 unsigned long long" in the
first draft ;-)
> I'd probably further wrap it with a flagbit_set and flagbit_tst to wrap
> the "figure out which byte, then which bit of that byte" logic, but that
> would be a wrapper around flagbits_at, anyway. It can come later.
Exactly. At that point, it is not about "what you could use commit
slab for" but is about "how you would implement unbounded set of
flag bits".
> We'd probably want the hot path of this (returning the actual pointer)
> to be inline, but not necessarily the parts about growing,...
Yeah, this was just a technology demonstration as your original.
prev parent reply other threads:[~2013-04-15 1:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-14 6:04 [PATCH 0/3] Using commit slab to replace indegree Junio C Hamano
2013-04-14 6:04 ` [PATCH 1/3] commit: allow associating auxiliary info on-demand Junio C Hamano
2013-04-14 15:12 ` Jeff King
2013-04-14 19:01 ` Junio C Hamano
2013-04-14 6:04 ` [PATCH 2/3] commit-slab: avoid large realloc Junio C Hamano
2013-04-14 15:28 ` Jeff King
2013-04-14 18:51 ` Junio C Hamano
2013-04-14 19:19 ` Jeff King
2013-04-15 1:29 ` Junio C Hamano
2013-04-14 6:04 ` [PATCH 3/3] commit-slab: introduce a macro to define a slab for new type Junio C Hamano
2013-04-14 18:41 ` Jeff King
2013-04-15 1:32 ` Junio C Hamano [this message]
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=7vppxw4lz9.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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).