Fix TinyUFO ahash in nightly Rust

I think ahash has this bug where the hash of &u64 and u64 are different
under nightly build. This works around that.
This commit is contained in:
Yuchen Wu 2024-02-28 13:37:41 -08:00 committed by Yuchen Wu
parent 8797329225
commit dd54b59d38
2 changed files with 4 additions and 3 deletions

1
.bleep Normal file
View file

@ -0,0 +1 @@
bc15229a4afa44364f388138e04cc05334937b5a

View file

@ -403,7 +403,7 @@ impl<K: Hash, T: Clone + Send + Sync> TinyUfo<K, T> {
///
/// Return a list of [KV] of key and `T` that are evicted
pub fn put(&self, key: K, data: T, weight: Weight) -> Vec<KV<T>> {
let key = self.random_status.hash_one(key);
let key = self.random_status.hash_one(&key);
self.queues.admit(key, data, weight, false, &self.buckets)
}
@ -422,13 +422,13 @@ impl<K: Hash, T: Clone + Send + Sync> TinyUfo<K, T> {
/// Compared to [Self::put], the hit ratio when using this function is reduced by about 0.5pp or less in
/// under zipf workloads.
pub fn force_put(&self, key: K, data: T, weight: Weight) -> Vec<KV<T>> {
let key = self.random_status.hash_one(key);
let key = self.random_status.hash_one(&key);
self.queues.admit(key, data, weight, true, &self.buckets)
}
#[cfg(test)]
fn peek_queue(&self, key: K) -> Option<bool> {
let key = self.random_status.hash_one(key);
let key = self.random_status.hash_one(&key);
self.buckets.pin().get(&key).map(|p| p.queue.value())
}
}