Reduce the lru key size from 20 to 8 bytes

This commit is contained in:
Clément Renault 2024-09-25 15:37:13 +02:00
parent 86d5e6d9ff
commit 52d7f3ed1c
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F
2 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ use crate::CboRoaringBitmapCodec;
#[derive(Debug)]
pub struct CboCachedSorter<MF> {
cache: Lru<SmallVec<[u8; 20]>, DelAddRoaringBitmap>,
cache: Lru<SmallVec<[u8; 8]>, DelAddRoaringBitmap>,
sorter: Sorter<MF>,
deladd_buffer: Vec<u8>,
cbo_buffer: Vec<u8>,

View File

@ -59,10 +59,10 @@ impl<K: Clone + Eq + Hash, V, S: BuildHasher> Lru<K, V, S> {
Entry::Vacant(vac) => {
let key = vac.key().clone();
if self.storage.is_full() {
let idx = self.storage.back_idx();
// It's fine to unwrap here because:
// * the cache capacity is non zero
// * the cache is full
let idx = self.storage.back_idx();
let node = self.storage.move_front(idx).unwrap();
let LruNode { key, value } = mem::replace(node, LruNode { key, value });
vac.insert(idx);
@ -128,8 +128,8 @@ struct FixedSizeList<T> {
// to find a free place.
// TODO remove the free list as it is always growing:
// we cannot remove entries from the map.
// Also, we probably do not need one of the front and back cursors.
free: Vec<usize>,
// TODO Also, we probably do not need one of the front and back cursors.
front: usize,
back: usize,
}