Skip to content

Commit

Permalink
perf:make txn share storage table catalog cache
Browse files Browse the repository at this point in the history
  • Loading branch information
crwen committed Mar 17, 2024
1 parent f8488f4 commit e2569a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/storage/kip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::sync::Arc;
pub struct KipStorage {
pub inner: Arc<storage::KipStorage>,
pub(crate) meta_cache: Arc<ShardingLruCache<TableName, Vec<StatisticsMeta>>>,
pub(crate) table_cache: Arc<ShardingLruCache<String, TableCatalog>>,
}

impl KipStorage {
Expand All @@ -31,10 +32,12 @@ impl KipStorage {
storage::KipStorage::open_with_config(Config::new(path).enable_level_0_memorization())
.await?;
let meta_cache = Arc::new(ShardingLruCache::new(128, 16, RandomState::new()).unwrap());
let table_cache = Arc::new(ShardingLruCache::new(128, 16, RandomState::new()).unwrap());

Ok(KipStorage {
inner: Arc::new(storage),
meta_cache,
table_cache,
})
}
}
Expand All @@ -47,15 +50,15 @@ impl Storage for KipStorage {

Ok(KipTransaction {
tx,
table_cache: ShardingLruCache::new(8, 2, RandomState::default())?,
table_cache: Arc::clone(&self.table_cache),
meta_cache: self.meta_cache.clone(),
})
}
}

pub struct KipTransaction {
tx: mvcc::Transaction,
table_cache: ShardingLruCache<String, TableCatalog>,
table_cache: Arc<ShardingLruCache<String, TableCatalog>>,
meta_cache: Arc<ShardingLruCache<TableName, Vec<StatisticsMeta>>>,
}

Expand Down

0 comments on commit e2569a0

Please sign in to comment.