Skip to content

Commit cf63c4c

Browse files
committed
Change the interest cache hasher to rapidhash
1 parent e63ef57 commit cf63c4c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tracing-log/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ rust-version = "1.65.0"
2121
default = ["log-tracer", "std"]
2222
std = ["log/std"]
2323
log-tracer = []
24-
interest-cache = ["lru", "ahash"]
24+
interest-cache = ["lru","rapidhash"]
2525

2626
[dependencies]
2727
tracing-core = { path = "../tracing-core", version = "0.1.28"}
2828
log = { version = "0.4.17" }
2929
once_cell = "1.13.0"
3030
lru = { version = "0.7.7", optional = true }
31-
ahash = { version = "0.7.7", optional = true }
31+
rapidhash = { version = "3.0.0", default-features = false, optional = true }
3232

3333
[dev-dependencies]
3434
tracing = { path = "../tracing", version = "0.1.35"}
3535
tracing-subscriber = { path = "../tracing-subscriber" }
36-
criterion = { version = "0.3.6", default-features = false }
36+
criterion = { version = "0.7.0", default-features = false }
3737

3838
[badges]
3939
maintenance = { status = "actively-maintained" }

tracing-log/src/interest_cache.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use ahash::AHasher;
21
use log::{Level, Metadata};
32
use lru::LruCache;
43
use once_cell::sync::Lazy;
4+
use rapidhash::fast::{RapidHasher, RandomState as RapidRandomState};
55
use std::cell::RefCell;
66
use std::hash::Hasher;
77
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -90,15 +90,15 @@ struct Key {
9090
struct State {
9191
min_verbosity: Level,
9292
epoch: usize,
93-
cache: LruCache<Key, u64, ahash::RandomState>,
93+
cache: LruCache<Key, u64, RapidRandomState>,
9494
}
9595

9696
impl State {
9797
fn new(epoch: usize, config: &InterestCacheConfig) -> Self {
9898
State {
9999
epoch,
100100
min_verbosity: config.min_verbosity,
101-
cache: LruCache::new(config.lru_cache_size),
101+
cache: LruCache::with_hasher(config.lru_cache_size, RapidRandomState::default()),
102102
}
103103
}
104104
}
@@ -175,7 +175,7 @@ pub(crate) fn try_cache(metadata: &Metadata<'_>, callback: impl FnOnce() -> bool
175175

176176
let target = metadata.target();
177177

178-
let mut hasher = AHasher::default();
178+
let mut hasher = RapidHasher::default();
179179
hasher.write(target.as_bytes());
180180

181181
const HASH_MASK: u64 = !1;

0 commit comments

Comments
 (0)