Closed charlesgregory closed 4 years ago
@charlesgregory How much of khashl is identical to khash? A bit it seems. Would it be sensible to factor out (e.g. the hash functions), or is it more important that we retain source-level homology for future updates?
@charlesgregory How much of khashl is identical to khash? A bit it seems. Would it be sensible to factor out (e.g. the hash functions), or is it more important that we retain source-level homology for future updates?
It appears that the uint and ulong hashing functions may be different for khash vs khashl. I think a factored-out pool of shared hashing functions is not out of the question. We can use aliases to keep decent source-level homology. Up to you though. https://github.com/charlesgregory/dklib/blob/bca6747bbeb4e1ff55063118a14b834152bb9716/source/dklib/khashl.d#L413-L436 https://github.com/charlesgregory/dklib/blob/bca6747bbeb4e1ff55063118a14b834152bb9716/source/dklib/khash.d#L456-L472
Interesting, didn't notice that. I was also thinking of the _put and _resize functions
I am happy to accept the code as is , if you'll move the benchmark to examples/
and revert the dubfile
@charlesgregory ping
@charlesgregory You'll also need to rebase on current master since we updated dubfile
As a side note I have found that the free statements in the dtors of both khash and khashl can cause SEGSEVs so in normal use I usually comment this out. I notice this most when making a hashmap of hashmaps.
kfree(cast(void*) this.keys);
kfree(cast(void*) this.flags);
kfree(cast(void*) this.vals);
Edit: I forgot I actually opened an issue for this #2
Did a rebase but I think I should've just done a merge. Either way I would do a squash merge to get rid of the commit history mess.
Also do you need to make the changes to khasl that @n8sh made to khash? (regarding inlineing, which I accepted, and parameter in
qualifier which is in the pending PR) ?
I messed up the rebase/merge so we are closing this pull request and opening a new one.
Added khashl and made some changes to the benchmark and dub file. Khashl is hash table that performs deletions without tombstones allowing it to have a smaller memory footprint for some sacrifices in speed. It uses fibonacci hashing. Described here.
attractivechaos says this about khashl:
Deletion speed vs bytes per key
Most notably:
Time, in msec, for n=500,000 operations benchmarked on WSL (Ryzen 1700); ldc2 -release
There are no retrieval times for the cached version as that benchmark uses integer keys and my khashl template prevents that at compile time as there should be no real benefit for integers.
attractivechaos says this about hash-caching: