From 2ed28187a7531f9fb68ff5cbb031ba87c967fbdc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jul 2026 21:05:38 +0000 Subject: [PATCH 1/2] deps: bump quick_cache from 0.6.22 to 0.7.0 Bumps [quick_cache](https://github.com/arthurprs/quick-cache) from 0.6.22 to 0.7.0. - [Release notes](https://github.com/arthurprs/quick-cache/releases) - [Commits](https://github.com/arthurprs/quick-cache/compare/v0.6.22...v0.7.0) --- updated-dependencies: - dependency-name: quick_cache dependency-version: 0.7.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 33 ++++----------------------------- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c229b1..9f4ab17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,19 +17,6 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" -[[package]] -name = "ahash" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" -dependencies = [ - "cfg-if", - "getrandom 0.3.4", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.4" @@ -545,12 +532,6 @@ dependencies = [ "foldhash 0.1.5", ] -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" - [[package]] name = "hashbrown" version = "0.17.1" @@ -874,13 +855,13 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick_cache" -version = "0.6.22" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c821816e9b928e20e92ed59bb3ac4aab321d16ca2316871c9fe7ca739cd477" +checksum = "403c1a912fec895cafb223201e368234842acb9220aaf08ab042ae89ba5f135c" dependencies = [ - "ahash", "equivalent", - "hashbrown 0.16.1", + "foldhash 0.2.0", + "hashbrown 0.17.1", "parking_lot", ] @@ -1240,12 +1221,6 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - [[package]] name = "wait-timeout" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index 6e54af8..8f51029 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ bench-support = { path = "bench-support" } criterion = "0.8" dhat = "0.3" lru = "0.18" -quick_cache = "0.6" +quick_cache = "0.7" serde_json = "1.0" chrono = "0.4" proptest = "1.11" From 76c3f349be83827541c39de666feecdaa7fc32a4 Mon Sep 17 00:00:00 2001 From: Thomas Korrison Date: Tue, 14 Jul 2026 20:02:29 +0100 Subject: [PATCH 2/2] fix: align LFU oracle tie-breaking --- Cargo.lock | 8 ++++---- src/ds/intrusive_list.rs | 10 ++++------ tests/abstract_models/reference/lfu.rs | 17 +++++++++-------- tests/policy_semantics/lfu_tests.rs | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f4ab17..5b7fbda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,9 +64,9 @@ checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "arbitrary" @@ -338,9 +338,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.18" +version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +checksum = "2d6914041f254d6e9176c01941b21115dcfb7089e55135a35411081bd106ef3f" dependencies = [ "crossbeam-utils", ] diff --git a/src/ds/intrusive_list.rs b/src/ds/intrusive_list.rs index a04cdc1..6e79008 100644 --- a/src/ds/intrusive_list.rs +++ b/src/ds/intrusive_list.rs @@ -871,11 +871,10 @@ impl IntrusiveList { #[inline] fn attach_front(&mut self, id: SlotId) -> Option<()> { let old_head = self.head; - if let Some(node) = self.arena.get_mut(id) { + { + let node = self.arena.get_mut(id)?; node.prev = None; node.next = old_head; - } else { - return None; } if let Some(old_head) = old_head { if let Some(head_node) = self.arena.get_mut(old_head) { @@ -891,11 +890,10 @@ impl IntrusiveList { #[inline] fn attach_back(&mut self, id: SlotId) -> Option<()> { let old_tail = self.tail; - if let Some(node) = self.arena.get_mut(id) { + { + let node = self.arena.get_mut(id)?; node.next = None; node.prev = old_tail; - } else { - return None; } if let Some(old_tail) = old_tail { if let Some(tail_node) = self.arena.get_mut(old_tail) { diff --git a/tests/abstract_models/reference/lfu.rs b/tests/abstract_models/reference/lfu.rs index c6c77ff..527ae69 100644 --- a/tests/abstract_models/reference/lfu.rs +++ b/tests/abstract_models/reference/lfu.rs @@ -3,7 +3,7 @@ //! **Source:** [`docs/testing/specs/policies/exact/lfu.md`](../../../docs/testing/specs/policies/exact/lfu.md) ยท //! [matrix.md](../../../docs/testing/specs/matrix.md) //! **Tier:** reference (spec-first oracle). -//! **Formulation:** `HashMap` + append-only `first_seen` log for FIFO tie-break; +//! **Formulation:** `HashMap` + append-only bucket-arrival log for FIFO tie-break; //! independent of [`FrequencyBuckets`](cachekit::ds::FrequencyBuckets). use std::collections::{HashMap, HashSet, VecDeque}; @@ -14,7 +14,7 @@ use crate::abstract_models::{HitMiss, ModelStep, Op, OracleExpectation, PolicyMo #[derive(Debug, Clone)] pub struct NaiveLfuModel { freq: HashMap, - first_seen: VecDeque, + bucket_arrivals: VecDeque, capacity: usize, } @@ -25,7 +25,7 @@ where pub fn new(capacity: usize) -> Self { Self { freq: HashMap::new(), - first_seen: VecDeque::new(), + bucket_arrivals: VecDeque::new(), capacity, } } @@ -42,9 +42,9 @@ where self.freq.values().copied().min() } - /// Last append index for `key` in the tie-break log (re-inserts append again). - fn last_seen_index(&self, key: &K) -> usize { - self.first_seen + /// Last bucket-arrival index for `key` (touches and re-inserts append again). + fn bucket_arrival_index(&self, key: &K) -> usize { + self.bucket_arrivals .iter() .rposition(|k| k == key) .unwrap_or(usize::MAX) @@ -56,7 +56,7 @@ where .iter() .filter(|(_, f)| **f == min) .map(|(k, _)| k) - .min_by_key(|k| self.last_seen_index(k)) + .min_by_key(|k| self.bucket_arrival_index(k)) .cloned() } @@ -69,6 +69,7 @@ where fn touch(&mut self, key: &K) -> bool { if let Some(f) = self.freq.get_mut(key) { *f = f.saturating_add(1); + self.bucket_arrivals.push_back(key.clone()); true } else { false @@ -84,7 +85,7 @@ where evicted = self.evict_victim(); } self.freq.insert(key.clone(), 1); - self.first_seen.push_back(key); + self.bucket_arrivals.push_back(key); evicted } diff --git a/tests/policy_semantics/lfu_tests.rs b/tests/policy_semantics/lfu_tests.rs index a86d82a..625b935 100644 --- a/tests/policy_semantics/lfu_tests.rs +++ b/tests/policy_semantics/lfu_tests.rs @@ -95,6 +95,20 @@ fn smoke_lfu_naive_agreement() { assert_models_agree(&mut naive, &mut current, &ops); } +#[test] +fn lfu_naive_agreement_uses_bucket_arrival_for_ties() { + let ops = [ + Op::Insert(1), + Op::Insert(2), + Op::Touch(2), + Op::Touch(1), + Op::EvictOne, + ]; + let mut naive = NaiveLfuModel::new(2); + let mut current = LfuModel::new(2); + assert_models_agree(&mut naive, &mut current, &ops); +} + #[test] fn smoke_lfu() { let ops = [