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

View file

@ -1,7 +1,7 @@
# TODO
## 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
functionality for checking if mutex is unlocked before quitting to
collect requests from channel (try_recv) up to a limit.

View file

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

View file

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

View file

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