Use hashbrown hashmap directly for faster hash (ahash)

This commit is contained in:
Joakim Frostegård 2020-04-12 13:19:07 +02:00
parent eaa42a26b7
commit e61c961126
5 changed files with 16 additions and 4 deletions

11
Cargo.lock generated
View file

@ -31,6 +31,7 @@ dependencies = [
"bittorrent_udp", "bittorrent_udp",
"cli_helpers", "cli_helpers",
"crossbeam-channel", "crossbeam-channel",
"hashbrown",
"histogram", "histogram",
"indexmap", "indexmap",
"mimalloc", "mimalloc",
@ -317,6 +318,16 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "hashbrown"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479e9d9a1a3f8c489868a935b557ab5710e3e223836da2ecd52901d88935cb56"
dependencies = [
"ahash",
"autocfg",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.10" version = "0.1.10"

View file

@ -1,7 +1,7 @@
# TODO # TODO
## aquatic ## aquatic
* Use hashbrown HashMap for faster hasher (or try SeaHash?) * thread 'main' panicked at 'overflow when subtracting duration from instant', src/libstd/time.rs:374:9
* Put connections and torrent in a struct behind a commong lock. Add * Put connections and torrent in a struct behind a commong lock. Add
functionality for checking if mutex is unlocked before quitting to functionality for checking if mutex is unlocked before quitting to
collect requests from channel (try_recv) up to a limit. collect requests from channel (try_recv) up to a limit.

View file

@ -15,6 +15,7 @@ name = "aquatic"
bittorrent_udp = { path = "../bittorrent_udp" } bittorrent_udp = { path = "../bittorrent_udp" }
cli_helpers = { path = "../cli_helpers" } cli_helpers = { path = "../cli_helpers" }
crossbeam-channel = "0.4" crossbeam-channel = "0.4"
hashbrown = "0.7"
histogram = "0.6" histogram = "0.6"
indexmap = "1" indexmap = "1"
mimalloc = { version = "0.1", default-features = false } mimalloc = { version = "0.1", default-features = false }

View file

@ -1,10 +1,10 @@
use std::collections::HashMap;
use std::net::{SocketAddr, IpAddr}; use std::net::{SocketAddr, IpAddr};
use std::sync::{Arc, atomic::AtomicUsize}; use std::sync::{Arc, atomic::AtomicUsize};
use std::time::Instant; use std::time::Instant;
use parking_lot::Mutex; use hashbrown::HashMap;
use indexmap::IndexMap; use indexmap::IndexMap;
use parking_lot::Mutex;
pub use bittorrent_udp::types::*; pub use bittorrent_udp::types::*;

View file

@ -3,7 +3,7 @@ use std::sync::atomic::Ordering;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use std::vec::Drain; use std::vec::Drain;
use parking_lot::{Mutex, MutexGuard}; use parking_lot::MutexGuard;
use crossbeam_channel::{Sender, Receiver}; use crossbeam_channel::{Sender, Receiver};
use rand::{SeedableRng, Rng, rngs::{SmallRng, StdRng}}; use rand::{SeedableRng, Rng, rngs::{SmallRng, StdRng}};