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

Re: What's cooking in git.git (Oct 2013, #06; Fri, 25)

From
Vicent Martí <tanoku@gmail.com>
Date
Oct 28, 2013, 16:16 UTC
Message-ID
<CAFFjANSnuS6_+uAd43AayojJyK-wj2wMxQ6DBD6JyN=A7xh2_A@mail.gmail.com>
In-Reply-To
<xmqq61shgzvn.fsf@gitster.dls.corp.google.com>
On Mon, Oct 28, 2013 at 4:48 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
>> jk/pack-bitmap adds khash.h, which from a first glance looks like yet
>> another hash table implementation. I was just wondering if kb's new
>> hash tables can cover the need of pack-bitmap.c too so we can remove
>> khash.h later..
>
> Good thinking ;-).
We use the khash tables to map:
    - sha1 (const char *) to (void *)
    - sha1 (const char *) to int

The new `hashmap.c` covers the first case quite well (albeit slightly more verbosely than I'd like), but in the second case it doesn't quite work. Since the new hash needs to embed the "struct hashmap_entry" on all its values (to allow for separate chaining), having it map to `int` keys requires a struct like this:

    struct sha1_position {
        struct hashmap_entry {
            struct hashmap_entry *next;
            unsigned int hash;
        };
        int position;
    }

khash on the other hand is capable of storing the position values as part of the hash table itself (i.e. `int **buckets`), and saves us from thousands of bytes of allocations + indirection.

I am not sure whether the consistency of having a single hash map warrants the performance and memory hits when operating on the extended index.

Please advice.

luv, vmg

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 9 in “What's cooking in git.git (Oct 2013, #06; Fri, 25)”
  1. Junio C HamanoOct 25, 2013
  2. Duy NguyenOct 26, 2013
  3. Junio C HamanoOct 28, 2013
  4. Vicent MartíOct 28, 2013
  5. Junio C HamanoOct 28, 2013
  6. Karsten BleesOct 28, 2013
  7. Vicent MartíOct 28, 2013
  8. Karsten BleesOct 29, 2013
  9. Karsten BleesNov 14, 2013

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.