Replace HashMap and IndexMap with indexmap_amortized

This will hopefully get down latency.
This commit is contained in:
Joakim Frostegård 2021-11-03 10:35:29 +01:00
parent 362ee7274f
commit b8073e4bd1
12 changed files with 55 additions and 41 deletions

View file

@ -28,7 +28,6 @@ futures = "0.3"
futures-rustls = "0.22"
glommio = { git = "https://github.com/DataDog/glommio.git", rev = "4e6b14772da2f4325271fbcf12d24cf91ed466e5" }
hashbrown = { version = "0.11.2", features = ["serde"] }
indexmap = "1"
log = "0.4"
mimalloc = { version = "0.1", default-features = false }
privdrop = "0.5"

View file

@ -3,8 +3,7 @@ use std::sync::Arc;
use std::time::Instant;
use aquatic_common::access_list::{create_access_list_cache, AccessListArcSwap, AccessListCache};
use hashbrown::HashMap;
use indexmap::IndexMap;
use aquatic_common::AHashIndexMap;
pub use aquatic_common::ValidUntil;
@ -66,7 +65,7 @@ pub struct Peer {
pub valid_until: ValidUntil,
}
pub type PeerMap = IndexMap<PeerId, Peer>;
pub type PeerMap = AHashIndexMap<PeerId, Peer>;
pub struct TorrentData {
pub peers: PeerMap,
@ -78,14 +77,14 @@ impl Default for TorrentData {
#[inline]
fn default() -> Self {
Self {
peers: IndexMap::new(),
peers: Default::default(),
num_seeders: 0,
num_leechers: 0,
}
}
}
pub type TorrentMap = HashMap<InfoHash, TorrentData>;
pub type TorrentMap = AHashIndexMap<InfoHash, TorrentData>;
#[derive(Default)]
pub struct TorrentMaps {