@@ -38,27 +38,22 @@ was indexmap, a hash table that has following properties:
38
38
- Fast to iterate.
39
39
- Indexed in compact space.
40
40
- Preserves insertion order **as long ** as you don't call ``.remove() ``.
41
- - Uses robin hood hashing just like Rust's libstd ``HashMap `` used to do
42
- (before std switched to hashbrown).
43
-
44
- - It's the usual backwards shift deletion, but only on the index vector, so
45
- it's cheaper because it's moving less memory around.
41
+ - Uses hashbrown for the inner table, just like Rust's libstd ``HashMap `` does.
46
42
47
43
Performance
48
44
-----------
49
45
50
46
``IndexMap `` derives a couple of performance facts directly from how it is constructed,
51
47
which is roughly:
52
48
53
- Two vectors, the first, sparse, with hashes and key-value indices, and the
54
- second, dense, the key-value pairs.
49
+ A raw hash table of key-value indices, and a vector of key-value pairs.
55
50
56
51
- Iteration is very fast since it is on the dense key-values.
57
- - Removal is fast since it moves memory areas only in the first vector ,
58
- and uses a single swap in the second vector.
59
- - Lookup is fast-ish because the hashes and indices are densely stored.
60
- Lookup also is slow-ish since hashes and key-value pairs are stored in
61
- separate places . (Visible when cpu caches size is limiting.)
52
+ - Removal is fast since it moves memory areas only in the table ,
53
+ and uses a single swap in the vector.
54
+ - Lookup is fast-ish because the initial 7-bit hash lookup uses SIMD, and indices are
55
+ densely stored. Lookup also is slow-ish since the actual key-value pairs are stored
56
+ separately . (Visible when cpu caches size is limiting.)
62
57
63
58
- In practice, ``IndexMap `` has been tested out as the hashmap in rustc in PR45282 _ and
64
59
the performance was roughly on par across the whole workload.
@@ -68,15 +63,6 @@ which is roughly:
68
63
.. _PR45282 : https://github.com/rust-lang/rust/pull/45282
69
64
70
65
71
- - Idea for more cache efficient lookup (This was implemented in 0.1.2).
72
-
73
- Current ``indices: Vec<Pos> ``. ``Pos `` is interpreted as ``(u32, u32) `` more
74
- or less when ``.raw_capacity() `` fits in 32 bits. ``Pos `` then stores both the lower
75
- half of the hash and the entry index.
76
- This means that the hash values in ``Bucket `` don't need to be accessed
77
- while scanning for an entry.
78
-
79
-
80
66
Recent Changes
81
67
==============
82
68
0 commit comments