Re:Uthash – C macros for hash tables and more
by macjc on Saturday March 26, 2022 @12:47AM
(#30809304)
This is probably the slowest commonly used hash table library.
[ Parent
| on HN ]
Re:Uthash – C macros for hash tables and more
by tirrex on Saturday March 26, 2022 @07:03AM
(#30810808)
https://github.com/tezc/sc/tree/master/map
For those who are interested in faster hashmaps, I tried bunch of hashmaps and this one performs better than others. This is for C. Maybe C++ has better hashmaps.
Re:Uthash – C macros for hash tables and more
by rurban on Saturday March 26, 2022 @04:28AM
(#30810219)
std::unordered_map is in the similar ballpark. linked lists, oom checks, integer key support.
Re:Uthash – C macros for hash tables and more
by marginalia_nu on Saturday March 26, 2022 @05:45AM
(#30810509)
In a "hold my beer"-moment, I've ported GNU Trove's hash map to use memory mapped files instead of allocated memory. With good reason, granted, and it's not commonly used, but compared to almost anything else, it is fairly slow.
Re:Uthash – C macros for hash tables and more
by spicybright on Saturday March 26, 2022 @06:31AM
(#30810687)
That sounds pretty interesting (in a sick way ;) ) Are you able to elaborate a bit more what you were doing?
Re:Uthash – C macros for hash tables and more
by marginalia_nu on Saturday March 26, 2022 @07:59AM
(#30811091)
I'm using it for the lexicon in my search engine.
I basically need a mapping from arbitrary short strings to unique integer identifiers, with a cardinality in the billions. Too much to keep in memory, most db solutions keel over as well.
Re:Uthash – C macros for hash tables and more
by rurban on Saturday March 26, 2022 @01:02PM
(#30813458)
for this I would use CHM, ordered minimal perfect hashes with external mmap'ed keys. still constant lookup, just the position needs to be stored in the value also.
Re:Uthash – C macros for hash tables and more
by marginalia_nu on Saturday March 26, 2022 @03:35PM
(#30814664)
Problem is I don't know the items beforehand, instead I need to build the hash as I encounter new pages. I don't know any way of reconcile that with a minimal perfect hash.
Re:Uthash – C macros for hash tables and more
by rurban on Saturday March 26, 2022 @04:07PM
(#30814922)
ok, with trillions keys creating a CHM MPH is risky, and needs a few secs.
then your external hash is good enough.
Re:Uthash – C macros for hash tables and more
by kllrnohj on Saturday March 26, 2022 @08:41AM
(#30811343)
And std::unordered_map is then the slow version in C++ compared to absl::flat_hash_map or folly::F14FastMap
Re:Uthash – C macros for hash tables and more
by hambaleeyo on Saturday March 26, 2022 @06:01AM
(#30810553)
Care to elaborate a bit?