Skip to content

Commit f685fd6

Browse files
committed
Swap to bools, atomic not needed
1 parent 92aaf00 commit f685fd6

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

oxcache/src/eviction.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub struct ChunkEvictionPolicy {
232232
nr_chunks_per_zone: Chunk,
233233
lru: LruCache<ChunkLocation, ()>,
234234
pq: ZonePriorityQueue,
235-
validity: Array2<AtomicBool>,
235+
validity: Array2<bool>,
236236
#[cfg(feature = "eviction-metrics")]
237237
pub metrics: Option<Arc<crate::eviction_metrics::EvictionMetrics>>,
238238
}
@@ -255,7 +255,7 @@ impl ChunkEvictionPolicy {
255255
// Initialize all chunks as invalid (false) - become valid on first write
256256
let validity = Array2::from_shape_fn(
257257
(nr_zones as usize, nr_chunks_per_zone as usize),
258-
|_| AtomicBool::new(false)
258+
|_| false
259259
);
260260

261261
Self {
@@ -276,23 +276,20 @@ impl ChunkEvictionPolicy {
276276
// Bounds check - zones/chunks outside our range
277277
assert!(!(loc.zone >= self.nr_zones || loc.index >= self.nr_chunks_per_zone));
278278
self.validity[[loc.zone as usize, loc.index as usize]]
279-
.load(Ordering::Relaxed)
280279
}
281280

282281
/// Mark chunk as valid (actively tracked)
283-
fn mark_valid(&self, loc: &ChunkLocation) {
282+
fn mark_valid(&mut self, loc: &ChunkLocation) {
284283
// Bounds check - zones/chunks outside our range
285284
assert!(!(loc.zone >= self.nr_zones || loc.index >= self.nr_chunks_per_zone));
286-
self.validity[[loc.zone as usize, loc.index as usize]]
287-
.store(true, Ordering::Relaxed);
285+
self.validity[[loc.zone as usize, loc.index as usize]] = true;
288286
}
289287

290288
/// Mark chunk as invalid (evicted but not yet cleaned)
291-
fn mark_invalid(&self, loc: &ChunkLocation) {
289+
fn mark_invalid(&mut self, loc: &ChunkLocation) {
292290
// Bounds check - ignore out of range chunks
293291
assert!(!(loc.zone >= self.nr_zones || loc.index >= self.nr_chunks_per_zone));
294-
self.validity[[loc.zone as usize, loc.index as usize]]
295-
.store(false, Ordering::Relaxed);
292+
self.validity[[loc.zone as usize, loc.index as usize]] = false
296293
}
297294
}
298295

0 commit comments

Comments
 (0)