by Robin_Message · 16y ago · 0 comments
One thing I'd add is that if you aren't exploiting the ordered nature of the keys within a trie - i.e. if your keys have no underlying substructure or you aren't doing linear scans through the key space - then you don't want a trie at all and you'd be better off with a hash table.
A hash table will be faster and use less memory if your keys are unstructured (imagine for a minute choosing random integers for your keys - then mod N is a good hash function for those keys, so it is obvious a hash table will work well for them, whereas a trie will waste space trying to find common prefixes between random keys.)
If you are accessing completely randomly, then the cache utilisation will be similar between a good trie and a hash table. If you are accessing some things more than others, then you should use a move-to-front hash table to be competitive.
It is obvious, but it is wrong. I observed Judy beating out many hash tables in specifically this situation, and comparing favorably to google's sparsehash. Given its much smaller code size and fewer dependencies this has demonstrated itself a huge win at my organization.
Link to my benchmark: http://reddit.com/r/programming/comments/bhxwh/hash_table_be...
I'd be interested to see 10 million 64-bit integers in Judy and DenseHash though. Since ten million is 0.2% of 2^32, in some sense lots of the potential key space is actually in use, so I'd expect a lot of sharing to be possible and a sparse trie to perform well.
Is there a 64-bit integer key Judy array you could test on?
Simply using the 64-bit integer as a 8-byte key is what I use.
Treating the 32-bit integer as 4-byte keys performs similarly to using the integer-API directly.
> I'd be interested to see 10 million 64-bit integers in Judy and DenseHash though
It's easy enough to check :)
Further, the article is only an announcement that some benchmarking would be happening later...
But (linked directly from the wikipedia article), this article gives benchmarking and a good argument that a "Judy array" is a rather over-engineered solution: http://www.nothings.org/computer/judy/ (and that article is linked to the wikipedia article).
- Bhavin