Re: [PATCH v2 01/10] Define a structure for object IDs.
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 15, 2015, 00:17 UTC
- Message-ID
- <CACsJy8CK=0QpsMpZKN6Js99xFRD6mpJW1id2BBQDMsV1DaHiPg@mail.gmail.com>
- In-Reply-To
- <xmqqbnjvw7c8.fsf@gitster.dls.corp.google.com>
On Sun, Mar 15, 2015 at 5:19 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 23 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes: > >>> Anyway, wouldn't this be all academic? I do not see how you would >>> keep the object name in the <pack, nth> format in-core, as the >>> obj_hash[] is a hashtable keyed by <sha-1>, and even when we switch >>> to a different hash, I cannot see how such a table to ensure the >>> singleton-ness of in-core objects can be keyed sometimes by <hash> >>> and by <pack, nth> in some other time. >> >> I'm implementing something to see how much we gain by avoiding object >> lookup. The current approach is having "struct object ** obj" in >> "struct packed_git", indexed by "nth". So when you have <pack, nth> >> and pack->obj[nth] is valid, you'll get to "struct object *" without >> hashing. > > But do you realize that the hashtable serves two purposes? Grab the > object from its name is one thing, and the other one I am not seeing > how you will make it work with "sometimes <sha-1> sometimes <pack,nth>" > is to ensure that we will have only one in-core copy for the same object. > We even walk the hashtable when we want to drop the flag bits from > all in-core objects, so even if you instanciated an in-core object > without going through the object name layer, the hashtable needs to > have a pointer to such a pointer, no?
Notice that the first time pack->obj[] is filled using lookup_object(). So yes, the hash table has all the pointers that pack->obj[] has. If somebody wants to remove an object out of hash table, then all pack->obj[] are invalidated, but I don't think we ever delete objects from hash table.
-- Duy