Benjamin Smedberg | 22 Apr 2007 01:11
Picon

Re: Hashtable performance

Boris Zbarsky wrote:
> Does anyone happen to recall how the performance parameters of
> PLDHashTable and PLHashTable compare?  I seem to recall something about
> PLDHashTable being more efficient in terms of memory usage and
> PLHashTable being faster, but I could be wrong... and it could depend on
> the exact
> 
> The reason I ask is that if what I recall is correct it might make sense
> to use PLHashTable for "temporary" hashtables (e.g. the GCTable in the
> cycle collector), no?

The primary difference is how the entry is allocated. In PLDHashTable, the
entry is allocated inline in the hash array. In PLHashTable, the entry is
allocated separately and the array points to it. Therefore in some (many?)
cases, PLHashTable will have many more allocations.

PLHashTable has some advantages: the entry class doesn't move in memory, so
external code can hold a pointer to it.

IIRC PLHashTable has some inefficiencies that I didn't like, e.g.
PLHashEntry keeps separate pointers to the key and value, which frequently
just point to offsets within the entry itself.

--BDS

Gmane