From: Junio C Hamano <gitster@pobox•com>
To: Karsten Blees <karsten.blees@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: What's cooking in git.git (Dec 2013, #02; Fri, 6)
Date: Mon, 09 Dec 2013 09:48:35 -0800 [thread overview]
Message-ID: <xmqq7gbd29vw.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <52A37D70.3090400@gmail.com> (Karsten Blees's message of "Sat, 07 Dec 2013 20:56:32 +0100")
Karsten Blees <karsten.blees@gmail•com> writes:
>> * kb/fast-hashmap (2013-11-18) 14 commits
>> (merged to 'next' on 2013-12-06 at f90be3d)
>
> Damn, a day too late :-) I found these two glitches today...is a
> fixup patch OK or should I do a reroll (or separate patch on top)?
A separate patch on top would be the most appropriate. People have
been looking at the change since mid November, and nobody noticed
the problem; having a separate fix on top is a good way to document
what the specific gotcha that can be easily missed is.
I think the patch you attached describes the issue well, possibly
with a retitle (perhaps "hashmap.h: make sure map entries are
tightly packed", or something.)
Thanks.
> --- 8< ---
> Subject: [PATCH] fixup! add a hashtable implementation that supports O(1) removal
>
> Use 'unsigned int' for hash-codes everywhere.
>
> Extending 'struct hashmap_entry' with an int-sized member shouldn't waste
> memory on 64-bit systems. This is already documented in api-hashmap.txt,
> but needs '__attribute__((__packed__))' to work. Reduces e.g.
>
> struct name_entry {
> struct hashmap_entry ent;
> int namelen;
> char *name;
> };
>
> from 32 to 24 bytes.
>
> Signed-off-by: Karsten Blees <blees@dcon•de>
> ---
> hashmap.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hashmap.h b/hashmap.h
> index f5b3b61..b64567b 100644
> --- a/hashmap.h
> +++ b/hashmap.h
> @@ -15,7 +15,7 @@ extern unsigned int memihash(const void *buf, size_t len);
>
> /* data structures */
>
> -struct hashmap_entry {
> +struct __attribute__((__packed__)) hashmap_entry {
> struct hashmap_entry *next;
> unsigned int hash;
> };
> @@ -43,7 +43,7 @@ extern void hashmap_free(struct hashmap *map, int free_entries);
>
> /* hashmap_entry functions */
>
> -static inline void hashmap_entry_init(void *entry, int hash)
> +static inline void hashmap_entry_init(void *entry, unsigned int hash)
> {
> struct hashmap_entry *e = entry;
> e->hash = hash;
next prev parent reply other threads:[~2013-12-09 17:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 23:52 What's cooking in git.git (Dec 2013, #02; Fri, 6) Junio C Hamano
2013-12-07 10:03 ` Felipe Contreras
2013-12-07 20:30 ` Felipe Contreras
2013-12-09 21:00 ` Junio C Hamano
2013-12-07 17:03 ` Thomas Rast
2013-12-09 22:33 ` Jeff King
2013-12-09 22:51 ` Junio C Hamano
2013-12-07 18:49 ` Matthieu Moy
2013-12-07 19:56 ` Karsten Blees
2013-12-07 22:23 ` Thomas Rast
2013-12-07 22:32 ` Karsten Blees
2013-12-08 10:20 ` Thomas Rast
2013-12-09 14:03 ` Karsten Blees
2013-12-09 20:08 ` Jonathan Nieder
2013-12-09 23:19 ` Karsten Blees
2013-12-09 23:45 ` Jonathan Nieder
2013-12-18 13:10 ` Karsten Blees
2013-12-18 14:05 ` Karsten Blees
2013-12-18 14:12 ` Karsten Blees
2013-12-09 17:43 ` Junio C Hamano
2013-12-09 17:48 ` Junio C Hamano [this message]
2013-12-18 13:41 ` [PATCH] hashmap.h: Use 'unsigned int' for hash-codes everywhere Karsten Blees
2013-12-18 17:46 ` Junio C Hamano
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=xmqq7gbd29vw.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=karsten.blees@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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