khash associative array / hash map / hash set

James Blachly james.blachly at gmail.com
Mon Aug 24 20:31:42 UTC 2020


On Monday, 24 August 2020 at 05:51:59 UTC, ikod wrote:
> On Monday, 24 August 2020 at 01:39:26 UTC, James Blachly wrote:
>> OH, I almost forgot the best part. It is crazy fast.
>>
>> https://attractivechaos.wordpress.com/2018/01/13/revisiting-hash-table-performance/
>> https://attractivechaos.wordpress.com/2019/12/28/deletion-from-hash-tables-without-tombstones/
>>
>> My naive benchmark shows -- compared to 
>> emsi_containers.HashMap -- 30% faster inserts, 80% faster 
>> serial retrieval and 70% faster random retrieval. Perhaps I am 
>> doing something wrong?
>>
>> James
>
> Thanks, nice job!
>
> You also may want to compare performance with 
> https://github.com/ikod/ikod-containers, just add dependency 
> from ikod-containers, then:
>
> import ikod.containers;
>
> and use ikod.containers.hashmap.HashMap as alias for container. 
> I squeezed everything I was able from the open-addressing hash 
> map.

Nice, thank you and great job! Performance looks very comparable 
and I would be happy to use your package as well. Perhaps it is 
time that Dlang have a faster canonical hashmap (phobos.next ?)

```
hashmap benchmarks
Inserts for HashMap finished in 518 milliseconds.
Inserts for khash finished in 549 milliseconds.
Serial Lookups for HashMap finished in 21 milliseconds.
Random lookups for HashMap finished in 41 milliseconds.
Confirming stored value of last lookup: 
7353ece9-506c-467f-9cb4-7686426fa828
Serial Lookups for khash finished in 12 milliseconds.
Random lookups for khash finished in 36 milliseconds.
Confirming stored value of last lookup: 
1164a2f1-e6cb-4072-89d9-23cec5cadd95
```

Repeated tests show that ikod.containers' HashMap is consistently 
faster on insertions, while khash is consistently faster on 
retrieval.



More information about the Digitalmars-d-announce mailing list