Skip to content

Commit 871c642

Browse files
committed
m: Try using ahash
Signed-off-by: John Nunley <[email protected]>
1 parent de1112b commit 871c642

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ exclude = ["/.*"]
1919
static = []
2020

2121
[dependencies]
22+
ahash = "0.8.11"
2223
async-task = "4.4.0"
2324
concurrent-queue = "2.5.0"
2425
fastrand = "2.0.0"

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
)]
4040
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
4141

42-
use std::collections::HashMap;
4342
use std::fmt;
4443
use std::marker::PhantomData;
4544
use std::panic::{RefUnwindSafe, UnwindSafe};
@@ -49,6 +48,7 @@ use std::sync::{Arc, Mutex, RwLock, TryLockError};
4948
use std::task::{Poll, Waker};
5049
use std::thread::{self, ThreadId};
5150

51+
use ahash::AHashMap;
5252
use async_task::{Builder, Runnable};
5353
use concurrent_queue::ConcurrentQueue;
5454
use futures_lite::{future, prelude::*};
@@ -693,7 +693,7 @@ struct State {
693693
/// Local queues created by runners.
694694
///
695695
/// These are keyed by the thread that the runner originated in.
696-
local_queues: RwLock<HashMap<ThreadId, Vec<Arc<LocalQueue>>>>,
696+
local_queues: RwLock<AHashMap<ThreadId, Vec<Arc<LocalQueue>>>>,
697697

698698
/// Set to `true` when a sleeping ticker is notified or no tickers are sleeping.
699699
notified: AtomicBool,
@@ -710,7 +710,7 @@ impl State {
710710
const fn new() -> State {
711711
State {
712712
queue: ConcurrentQueue::unbounded(),
713-
local_queues: RwLock::new(HashMap::new()),
713+
local_queues: RwLock::new(AHashMap::new()),
714714
notified: AtomicBool::new(true),
715715
sleepers: Mutex::new(Sleepers {
716716
count: 0,
@@ -1207,7 +1207,7 @@ fn debug_state(state: &State, name: &str, f: &mut fmt::Formatter<'_>) -> fmt::Re
12071207
}
12081208

12091209
/// Debug wrapper for the local runners.
1210-
struct LocalRunners<'a>(&'a RwLock<HashMap<ThreadId, Vec<Arc<LocalQueue>>>>);
1210+
struct LocalRunners<'a>(&'a RwLock<AHashMap<ThreadId, Vec<Arc<LocalQueue>>>>);
12111211

12121212
impl fmt::Debug for LocalRunners<'_> {
12131213
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

0 commit comments

Comments
 (0)