git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] treewide: switch to khashl for memory savings

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 27, 2024, 21:54 UTC
Message-ID
<xmqq7chn1gtx.fsf@gitster.g>
In-Reply-To
<20240327093710.GA847433@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 31 quoted lines
> On Tue, Mar 26, 2024 at 10:48:40AM -0700, Junio C Hamano wrote:
>
>> $ 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.
>
> Probably:
>
> diff --git a/khashl.h b/khashl.h
> index 8fcebed237..1e724bbf88 100644
> --- a/khashl.h
> +++ b/khashl.h
> @@ -116,7 +116,7 @@ static kh_inline khint_t __kh_h2b(khint_t hash, khint_t bits) { return hash * 26
>  
>  #define __KHASHL_IMPL_RESIZE(SCOPE, HType, prefix, khkey_t, __hash_fn, __hash_eq) \
>  	SCOPE void prefix##_resize(HType *h, khint_t new_n_buckets) { \
> -		khint32_t *new_used = 0; \
> +		khint32_t *new_used = NULL; \
>  		khint_t j = 0, x = new_n_buckets, n_buckets, new_bits, new_mask; \
>  		while ((x >>= 1) != 0) ++j; \
>  		if (new_n_buckets & (new_n_buckets - 1)) ++j; \
>
> -Peff

Spot on. With this (and the other two 0 -> NULL fixes), and with the SWAP() thing in brian's credential series fixed, the tip of 'seen' passes the static-analysis and sparse CI jobs again.

Thanks.
Previous: Jeff KingNext: Eric Wong
Message 6 of 11 in “switch to tombstone-free khashl table”
  1. 0/3 switch to tombstone-free khashl tableEric Wong, Mar 25, 2024
  2. 1/3 list-objects-filter: use kh_size APIEric Wong, Mar 25, 2024
  3. 2/3 treewide: switch to khashl for memory savingsEric Wong, Mar 25, 2024
  4. Junio C HamanoMar 26, 2024
  5. Jeff KingMar 27, 2024
  6. Junio C HamanoMar 27, 2024
  7. 3/3 khashl: fix ensemble lookups on empty tableEric Wong, Mar 25, 2024
  8. 4/3 switch to khashl ensembleEric Wong, Mar 25, 2024
  9. Junio C HamanoMar 26, 2024
  10. Junio C HamanoApr 19, 2024
  11. Eric WongApr 19, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.