Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tracing-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ rust-version = "1.65.0"
default = ["log-tracer", "std"]
std = ["log/std"]
log-tracer = []
interest-cache = ["lru", "ahash"]
interest-cache = ["lru","rapidhash"]

[dependencies]
tracing-core = { path = "../tracing-core", version = "0.1.28"}
log = { version = "0.4.17" }
once_cell = "1.13.0"
lru = { version = "0.7.7", optional = true }
ahash = { version = "0.7.7", optional = true }
rapidhash = { version = "3.0.0", default-features = false, optional = true }

[dev-dependencies]
tracing = { path = "../tracing", version = "0.1.35"}
tracing-subscriber = { path = "../tracing-subscriber" }
criterion = { version = "0.3.6", default-features = false }
criterion = { version = "0.7.0", default-features = false }

[badges]
maintenance = { status = "actively-maintained" }
Expand Down
8 changes: 4 additions & 4 deletions tracing-log/src/interest_cache.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ahash::AHasher;
use log::{Level, Metadata};
use lru::LruCache;
use once_cell::sync::Lazy;
use rapidhash::fast::{RapidHasher, RandomState as RapidRandomState};
use std::cell::RefCell;
use std::hash::Hasher;
use std::sync::atomic::{AtomicUsize, Ordering};
Expand Down Expand Up @@ -90,15 +90,15 @@ struct Key {
struct State {
min_verbosity: Level,
epoch: usize,
cache: LruCache<Key, u64, ahash::RandomState>,
cache: LruCache<Key, u64, RapidRandomState>,
}

impl State {
fn new(epoch: usize, config: &InterestCacheConfig) -> Self {
State {
epoch,
min_verbosity: config.min_verbosity,
cache: LruCache::new(config.lru_cache_size),
cache: LruCache::with_hasher(config.lru_cache_size, RapidRandomState::default()),
}
}
}
Expand Down Expand Up @@ -175,7 +175,7 @@ pub(crate) fn try_cache(metadata: &Metadata<'_>, callback: impl FnOnce() -> bool

let target = metadata.target();

let mut hasher = AHasher::default();
let mut hasher = RapidHasher::default();
hasher.write(target.as_bytes());

const HASH_MASK: u64 = !1;
Expand Down