Redesign dictionary: use Vector{DictSlot{K,V}} #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since Julia does not have atomics for arrays, supporting boxed Julia objects in a hash table requires indirection (i.e., a
mutable struct
) somewhere at the moment because no atomic operation can be defined onVector{Any}
. Previously,LinearProbingDict
was using amutable struct
only for "storage" and the actual linearization was done on a dense array using 128 bit CAS (based on Maier et al. (2019)). However, it required complex key/value storage management to actually store objects in the hash table. It turned out that just usingVector{DictSlot{K,V}}
(whereDictSlot{K,V}
is amutable struct
) is more straightforward and beneficial in terms of performance. The important optimization to make it practical is to avoid copyingDictSlot{K,V}
during migration.A nice side-effect of this approach is that it gets rid of the "torn" 64-bit load which is not likely to be supported in Julia. It is now possible to separate key and value to distinct
Vector
s if atomics onVector{Any}
is supported at some point. This is more likely to be supported than updating key/value location directly inVector{Pair{Any,Any}}
.