diff --git a/Cargo.lock b/Cargo.lock index bbe6059..94e4c9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/TODO.md b/TODO.md index 9f42c89..ff18748 100644 --- a/TODO.md +++ b/TODO.md @@ -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. diff --git a/aquatic/Cargo.toml b/aquatic/Cargo.toml index 94e59ce..028bd5b 100644 --- a/aquatic/Cargo.toml +++ b/aquatic/Cargo.toml @@ -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 } diff --git a/aquatic/src/lib/common.rs b/aquatic/src/lib/common.rs index 834579a..a119c98 100644 --- a/aquatic/src/lib/common.rs +++ b/aquatic/src/lib/common.rs @@ -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::*; diff --git a/aquatic/src/lib/handlers.rs b/aquatic/src/lib/handlers.rs index 41fa3ed..702a931 100644 --- a/aquatic/src/lib/handlers.rs +++ b/aquatic/src/lib/handlers.rs @@ -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}};