Skip to content

Commit

Permalink
Negative caching for point-read items such as transactions and effects (
Browse files Browse the repository at this point in the history
#20315)

Add negative caching for effects and other point-read items. This
dramatically reduces requests to the DB during test runs.
  • Loading branch information
mystenmark authored Dec 14, 2024
1 parent db080ac commit 03586ce
Show file tree
Hide file tree
Showing 4 changed files with 299 additions and 97 deletions.
21 changes: 0 additions & 21 deletions crates/sui-core/src/execution_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,27 +880,6 @@ macro_rules! implement_passthrough_traits {
}
}

impl StateSyncAPI for $implementor {
fn insert_transaction_and_effects(
&self,
transaction: &VerifiedTransaction,
transaction_effects: &TransactionEffects,
) {
self.store
.insert_transaction_and_effects(transaction, transaction_effects)
.expect("db error");
}

fn multi_insert_transaction_and_effects(
&self,
transactions_and_effects: &[VerifiedExecutionData],
) {
self.store
.multi_insert_transaction_and_effects(transactions_and_effects.iter())
.expect("db error");
}
}

impl TestingAPI for $implementor {
fn database_for_testing(&self) -> Arc<AuthorityStore> {
self.store.clone()
Expand Down
1 change: 1 addition & 0 deletions crates/sui-core/src/execution_cache/cache_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub struct MonotonicCache<K, V> {
key_generation: Vec<AtomicU64>,
}

#[derive(Copy, Clone)]
pub enum Ticket {
// Read tickets are used when caching the result of a read from the db.
// They are only valid if the generation number matches the current generation.
Expand Down
21 changes: 21 additions & 0 deletions crates/sui-core/src/execution_cache/passthrough_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,25 @@ impl ExecutionCacheCommit for PassthroughCache {
}
}

impl StateSyncAPI for PassthroughCache {
fn insert_transaction_and_effects(
&self,
transaction: &VerifiedTransaction,
transaction_effects: &TransactionEffects,
) {
self.store
.insert_transaction_and_effects(transaction, transaction_effects)
.expect("db error");
}

fn multi_insert_transaction_and_effects(
&self,
transactions_and_effects: &[VerifiedExecutionData],
) {
self.store
.multi_insert_transaction_and_effects(transactions_and_effects.iter())
.expect("db error");
}
}

implement_passthrough_traits!(PassthroughCache);
Loading

0 comments on commit 03586ce

Please sign in to comment.