tag | d64c9440a6fe5e25eedd7ed0a920ca93ae010468 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Mon Sep 23 16:19:09 2024 -0700 |
object | 291a6532f43e13f157ac6f2dff62981adaa98d31 |
frc_350820960 (12365824,com.google.android.art,com.google.android.go.art)
commit | 291a6532f43e13f157ac6f2dff62981adaa98d31 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed May 22 16:59:00 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed May 22 16:59:00 2024 +0000 |
tree | cf6a92e9d6da3b5438163ad113a806b10d68209f | |
parent | 03c0d1e063099d9aff826ad282df3c6f0bcb3753 [diff] | |
parent | a9f5c771e8397e1f26930d55c42af0213677eb34 [diff] |
Snap for 11873904 from a9f5c771e8397e1f26930d55c42af0213677eb34 to aml-frc-release Change-Id: I6ba96edb03859dd55fe55ce996e47b69a0cd3f2d
A pure-Rust hash table which preserves (in a limited sense) insertion order.
This crate implements compact map and set data-structures, where the iteration order of the keys is independent from their hash or value. It preserves insertion order (except after removals), and it allows lookup of entries by either hash table key or numerical index.
Note: this crate was originally released under the name ordermap
, but it was renamed to indexmap
to better reflect its features.
This was inspired by Python 3.6's new dict implementation (which remembers the insertion order and is fast to iterate, and is compact in memory).
Some of those features were translated to Rust, and some were not. The result was indexmap, a hash table that has following properties:
.remove()
.HashMap
does.IndexMap
derives a couple of performance facts directly from how it is constructed, which is roughly:
A raw hash table of key-value indices, and a vector of key-value pairs.
Iteration is very fast since it is on the dense key-values.
Removal is fast since it moves memory areas only in the table, and uses a single swap in the vector.
Lookup is fast-ish because the initial 7-bit hash lookup uses SIMD, and indices are densely stored. Lookup also is slow-ish since the actual key-value pairs are stored separately. (Visible when cpu caches size is limiting.)
In practice, IndexMap
has been tested out as the hashmap in rustc in PR45282 and the performance was roughly on par across the whole workload.
If you want the properties of IndexMap
, or its strongest performance points fits your workload, it might be the best hash table implementation.
See RELEASES.md.