From: Junio C Hamano <gitster@pobox.com>
To: Eric Wong <e@80x24.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/3] treewide: switch to khashl for memory savings
Date: Tue, 26 Mar 2024 10:48:40 -0700 [thread overview]
Message-ID: <xmqqttksanpj.fsf@gitster.g> (raw)
In-Reply-To: <20240325230704.262272-3-e@80x24.org> (Eric Wong's message of "Mon, 25 Mar 2024 23:07:02 +0000")
Eric Wong <e@80x24.org> writes:
> khashl is an updated version of khash with less memory overhead
> (one bit/bucket instead of two) than the original khash and
> similar overall performance. Insertions are simpler (linear
> probing) but deletions may be slightly slower[1]. Of course,
> the majority of hash tables in git do not delete individual
> elements.
$ make builtin/fast-import.sp ;# part of make sparse
SP builtin/fast-import.c
builtin/fast-import.c: note: in included file (through oidset.h, packfile.h):
khashl.h:516:1: error: Using plain integer as NULL pointer
khashl.h:516:1: error: Using plain integer as NULL pointer
make: *** [Makefile:3237: builtin/fast-import.sp] Error 1
I found IMPL_GET and IMPL_DEL's use of (h->keys == 0) were giving
one of these two, and managed to reduce the error to just one with
the attached patch, but I don't know what the other error is coming
from.
khashl.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git c/khashl.h w/khashl.h
index 8ffe80fbb2..663e36cd2d 100644
--- c/khashl.h
+++ w/khashl.h
@@ -101,7 +101,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
#define __KHASHL_IMPL_GET(SCOPE, HType, prefix, khkey_t, __hash_fn, __hash_eq) \
SCOPE khint_t prefix##_getp_core(const HType *h, const khkey_t *key, khint_t hash) { \
khint_t i, last, n_buckets, mask; \
- if (h->keys == 0) return 0; \
+ if (!h->keys) return 0; \
n_buckets = (khint_t)1U << h->bits; \
mask = n_buckets - 1U; \
i = last = __kh_h2b(hash, h->bits); \
@@ -183,7 +183,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
#define __KHASHL_IMPL_DEL(SCOPE, HType, prefix, khkey_t, __hash_fn) \
SCOPE int prefix##_del(HType *h, khint_t i) { \
khint_t j = i, k, mask, n_buckets; \
- if (h->keys == 0) return 0; \
+ if (!h->keys) return 0; \
n_buckets = (khint_t)1U<<h->bits; \
mask = n_buckets - 1U; \
while (1) { \
next prev parent reply other threads:[~2024-03-26 17:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 23:07 [PATCH 0/3] switch to tombstone-free khashl table Eric Wong
2024-03-25 23:07 ` [PATCH 1/3] list-objects-filter: use kh_size API Eric Wong
2024-03-25 23:07 ` [PATCH 2/3] treewide: switch to khashl for memory savings Eric Wong
2024-03-26 17:48 ` Junio C Hamano [this message]
2024-03-27 9:37 ` Jeff King
2024-03-27 21:54 ` Junio C Hamano
2024-03-25 23:07 ` [PATCH 3/3] khashl: fix ensemble lookups on empty table Eric Wong
2024-03-25 23:07 ` [REJECT 4/3] switch to khashl ensemble Eric Wong
2024-03-26 17:40 ` [PATCH 0/3] switch to tombstone-free khashl table Junio C Hamano
2024-04-19 21:31 ` Junio C Hamano
2024-04-19 21:46 ` Eric Wong
-- strict thread matches above, loose matches on Subject: below --
2024-03-28 10:13 Eric Wong
2024-03-28 10:13 ` [PATCH 2/3] treewide: switch to khashl for memory savings Eric Wong
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqttksanpj.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=e@80x24.org \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).