@@ -38,27 +38,22 @@ was indexmap, a hash table that has following properties:
3838- Fast to iterate.
3939- Indexed in compact space.
4040- 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.
4642
4743Performance
4844-----------
4945
5046``IndexMap `` derives a couple of performance facts directly from how it is constructed,
5147which is roughly:
5248
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.
5550
5651- 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.)
6257
6358- In practice, ``IndexMap `` has been tested out as the hashmap in rustc in PR45282 _ and
6459 the performance was roughly on par across the whole workload.
@@ -68,15 +63,6 @@ which is roughly:
6863.. _PR45282 : https://github.com/rust-lang/rust/pull/45282
6964
7065
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-
8066Recent Changes
8167==============
8268
0 commit comments