Open jakoschiko opened 1 month ago
Could definitely be worth looking into. There is an collisions
function that can be used to track of collisions, load rate is factor here as well. There will almost always be some collisions though.
One thing to keep in mind is that I found the benchmarks to sometimes change between runs so it is wise to run it a couple of times to get a baseline. Changing the element count makes the bench mark more stable but take more time. Preferably there is benchmarks for different element counts, but I'm too lazy ^^
Could definitely be worth looking into.
I will do it. Maybe it's worth to add more benchmarks before that. How do you feel about introducing the dependency smallvec
?
One thing to keep in mind is that I found the benchmarks to sometimes change between runs so it is wise to run it a couple of times to get a baseline. Changing the element count makes the bench mark more stable but take more time.
I ran it multiple times and it was consistent.
Preferably there is benchmarks for different element counts, but I'm too lazy ^^
Would you mind switching to another bench lib like criterion or divan (my preferred choice)? They support this out of the box. And the current benchmark requires a nightly compiler which is a little bit annoying.
Looked a bit at both of the benchmark libs. Both don't seems very active so I suppose divan should be fine. I would be fine with adding a dependency in this case.
Currently
IntMap
stores it values in this data structure:If I understand correctly the inner
Vec
is used for entries with a hash collision. I would assume that hash collisions are rare, so allocating aVec
for storing a single entry might be too expensive.A simple solution to this problem could be
SmallVec
:I refactored
IntMap
and ran the benchmarks included in this repo:It doesn't seem to make a difference. But then I ran the benchmarks mentioned #46:
This looks good, isn't it? My changes are on this branch.
What do you think? Is it worth to investigate this further?