From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/6] rerere: use strmap to store rerere directories
Date: Thu, 28 Jan 2021 11:52:20 -0800 [thread overview]
Message-ID: <xmqq8s8cx2iz.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <YBJa98B1a6mP/Bsx@coredump.intra.peff.net> (Jeff King's message of "Thu, 28 Jan 2021 01:34:31 -0500")
Jeff King <peff@peff.net> writes:
> Subject: [PATCH] rerere: use strmap to store rerere directories
>
> We store a struct for each directory we access under .git/rr-cache. The
> structs are kept in an array sorted by the binary hash associated with
> their name (and we do lookups with a binary search).
>
> This works OK, but there are a few small downsides:
>
> - the amount of code isn't huge, but it's more than we'd need using one
> of our other stock data structures
>
> - the insertion into a sorted array is quadratic (though in practice
> it's unlikely anybody has enough conflicts for this to matter)
>
> - it's intimately tied to the representation of an object hash. This
> isn't a big deal, as the conflict ids we generate use the same hash,
> but it produces a few awkward bits (e.g., we are the only user of
> hash_pos() that is not using object_id).
>
> Let's instead just treat the directory names as strings, and store them
> in a strmap. This is less code, and removes the use of hash_pos().
Nice. I didn't realize that this part is so well isolated that
another table implementation can easily be dropped in (it was a long
time since I stared at this part of the system, back when I was
extending it to handle <preimage,postimage> pairs that share the
same conflict IDs, which was quite tricky to get right).
> This one might be controversial, or at least considered unnecessary
> churn. Because the benefits I listed above are pretty negligible, and
> really my ulterior motive is getting rid of the call to hash_pos().
No objection from me. Thanks.
next prev parent reply other threads:[~2021-01-28 20:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 6:12 [PATCH 0/6] convert hash_pos() to oid_pos() Jeff King
2021-01-28 6:12 ` [PATCH 1/6] commit_graft_pos(): take an oid instead of a bare hash Jeff King
2021-01-28 12:57 ` Derrick Stolee
2021-01-28 6:14 ` [PATCH 2/6] rerere: check dirname format while iterating rr_cache directory Jeff King
2021-01-28 6:16 ` [PATCH 3/6] rerere: tighten rr-cache dirname check Jeff King
2021-01-28 22:35 ` Taylor Blau
2021-01-28 6:19 ` [PATCH 4/6] rerere: use strmap to store rerere directories Jeff King
2021-01-28 6:34 ` Jeff King
2021-01-28 19:52 ` Junio C Hamano [this message]
2021-01-28 6:38 ` Junio C Hamano
2021-01-28 6:51 ` Jeff King
2021-01-28 6:19 ` [PATCH 5/6] hash_pos(): convert to oid_pos() Jeff King
2021-01-28 22:48 ` Taylor Blau
2021-01-29 1:18 ` Jeff King
2021-01-28 6:20 ` [PATCH 6/6] oid_pos(): access table through const pointers Jeff King
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=xmqq8s8cx2iz.fsf@gitster.c.googlers.com \
--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).