aboutsummaryrefslogtreecommitdiffhomepage
path: root/tinyufo
diff options
context:
space:
mode:
authorYuchen Wu <[email protected]>2024-02-28 13:37:41 -0800
committerYuchen Wu <[email protected]>2024-03-01 13:47:27 -0800
commitdd54b59d38080f9de072a2e4f720c8da22fb0dfd (patch)
treeaa9f2f0dde346c1100428202636a51f3d49077e1 /tinyufo
parent8797329225018c4d0ab990166dd020338ae292dc (diff)
downloadpingora-dd54b59d38080f9de072a2e4f720c8da22fb0dfd.tar.gz
pingora-dd54b59d38080f9de072a2e4f720c8da22fb0dfd.zip
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.
Diffstat (limited to 'tinyufo')
-rw-r--r--tinyufo/src/lib.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/tinyufo/src/lib.rs b/tinyufo/src/lib.rs
index 879e373..9a9e79c 100644
--- a/tinyufo/src/lib.rs
+++ b/tinyufo/src/lib.rs
@@ -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())
}
}