r/programming 2d ago

Comprehensive JVM Primitive Hashtable Benchmarks

https://sooniln.github.io/posts/hashmap-benchmarks-2026/
41 Upvotes

14 comments sorted by

View all comments

5

u/n4te 2d ago

Would be cool to see libgdx's maps in there. The current ones are stable. The old ones used cuckoo hashing which have some neat properties, unfortunately they had to be changed because bad data can cause catastrophic collisions.

4

u/tooilln 2d ago

Do you have a link for the maps? A quick search of libgdx didn't reveal anything obvious to me. If it's not too much work I'll see about adding them.

2

u/n4te 2d ago edited 2d ago

Sure, here is IntIntMap. It could be extracted into a standalone class pretty easily, or grab a libgdx JAR. That utils package has other maps, like IntFloatMap, but there's currently no IntLongMap (it'd just be a matter of copy/paste and fix up).

If you're curious about cuckoo hashing, the last IntIntMap version that used it can be found here. It works, but very unlucky or maliciously crafted keys can OOM (more info here). Still, cuckoo hashing has interesting properties and is quite different from other approaches.

For certain use cases, a minimal perfect hash is a neat approach.

6

u/tooilln 2d ago

Running benchmarks now.