aboutsummaryrefslogtreecommitdiffhomepage
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
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.
-rw-r--r--.bleep1
-rw-r--r--tinyufo/src/lib.rs6
2 files changed, 4 insertions, 3 deletions
diff --git a/.bleep b/.bleep
new file mode 100644
index 0000000..87cf892
--- /dev/null
+++ b/.bleep
@@ -0,0 +1 @@
+bc15229a4afa44364f388138e04cc05334937b5a \ No newline at end of file
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())
}
}