Skip to content

Commit 3bba6b1

Browse files
committed
m: Try using ahash
Signed-off-by: John Nunley <[email protected]>
1 parent e5faacc commit 3bba6b1

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
@@ -15,6 +15,7 @@ categories = ["asynchronous", "concurrency"]
1515
exclude = ["/.*"]
1616

1717
[dependencies]
18+
ahash = "0.8.11"
1819
async-task = "4.4.0"
1920
concurrent-queue = "2.0.0"
2021
fastrand = "2.0.0"

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
html_logo_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
3939
)]
4040

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

50+
use ahash::AHashMap;
5151
use async_task::{Builder, Runnable};
5252
use concurrent_queue::ConcurrentQueue;
5353
use futures_lite::{future, prelude::*};
@@ -715,7 +715,7 @@ struct State {
715715
/// Local queues created by runners.
716716
///
717717
/// These are keyed by the thread that the runner originated in.
718-
local_queues: RwLock<HashMap<ThreadId, Vec<Arc<LocalQueue>>>>,
718+
local_queues: RwLock<AHashMap<ThreadId, Vec<Arc<LocalQueue>>>>,
719719

720720
/// Set to `true` when a sleeping ticker is notified or no tickers are sleeping.
721721
notified: AtomicBool,
@@ -732,7 +732,7 @@ impl State {
732732
fn new() -> State {
733733
State {
734734
queue: ConcurrentQueue::unbounded(),
735-
local_queues: RwLock::new(HashMap::new()),
735+
local_queues: RwLock::new(AHashMap::new()),
736736
notified: AtomicBool::new(true),
737737
sleepers: Mutex::new(Sleepers {
738738
count: 0,
@@ -1185,7 +1185,7 @@ fn debug_executor(executor: &Executor<'_>, name: &str, f: &mut fmt::Formatter<'_
11851185
}
11861186

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

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

0 commit comments

Comments
 (0)