Skip to content

Commit

Permalink
Beginning of WritebackCache (#16177)
Browse files Browse the repository at this point in the history
## Description 

Initial outline of WritebackCache, showing overall design of cache.

All object-lock related code is todo!() for now. That code is extremely
tricky and deserves its own PR.

WritebackCache is not yet used.

## Test Plan 

At this point: unittests + concurrent writer/reader test which is able
to find the bug we had earlier where we wrote tombstones after new
objects
  • Loading branch information
mystenmark authored Feb 23, 2024
1 parent dff910a commit 09c9759
Show file tree
Hide file tree
Showing 14 changed files with 2,585 additions and 74 deletions.
122 changes: 106 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ criterion = { version = "0.5.0", features = [
] }
crossterm = "0.25.0"
csv = "1.2.1"
dashmap = "5.4.0"
dashmap = "5.5.3"
# datatest-stable = "0.1.2"
datatest-stable = { git = "https://github.com/nextest-rs/datatest-stable.git", rev = "72db7f6d1bbe36a5407e96b9488a581f763e106f" }
derivative = "2.2.0"
Expand Down Expand Up @@ -360,6 +360,7 @@ markdown-gen = "1.2.1"
match_opt = "0.1.2"
mime = "0.3"
mockall = "0.11.4"
moka = { version = "0.12", default-features = false, features = ["sync", "atomic64"] }
more-asserts = "0.3.1"
msim = { git = "https://github.com/MystenLabs/mysten-sim.git", rev = "1a52783d6600ecc22e15253a982f77881bd47c77", package = "msim" }
msim-macros = { git = "https://github.com/MystenLabs/mysten-sim.git", rev = "1a52783d6600ecc22e15253a982f77881bd47c77", package = "msim-macros" }
Expand Down
6 changes: 6 additions & 0 deletions crates/sui-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ test-fuzz.workspace = true
sui-macros.workspace = true
sui-protocol-config.workspace = true

# moka uses `quanta` by default for timing, which is not compatible with the simulator
[target.'cfg(msim)'.dependencies]
moka = { workspace = true, default-features = false, features = ["sync", "atomic64"] }
[target.'cfg(not(msim))'.dependencies]
moka = { workspace = true, features = ["sync"] }

[[example]]
name = "generate-format"
path = "src/generate_format.rs"
Expand Down
16 changes: 4 additions & 12 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2663,17 +2663,6 @@ impl AuthorityState {
.enqueue_certificates(certs, epoch_store)
}

// NB: This must only be called at time of reconfiguration. We take the execution lock write
// guard as an argument to ensure that this is the case.
fn clear_object_per_epoch_marker_table(
&self,
execution_guard: &ExecutionLockWriteGuard<'_>,
) -> SuiResult<()> {
self.execution_cache
.clear_object_per_epoch_marker_table(execution_guard);
Ok(())
}

fn create_owner_index_if_empty(
&self,
genesis_objects: &[Object],
Expand Down Expand Up @@ -2763,8 +2752,12 @@ impl AuthorityState {

self.committee_store.insert_new_committee(&new_committee)?;
let mut execution_lock = self.execution_lock_for_reconfiguration().await;
// TODO: revert_uncommitted_epoch_transactions will soon be unnecessary -
// clear_state_end_of_epoch() can simply drop all uncommitted transactions
self.revert_uncommitted_epoch_transactions(cur_epoch_store)
.await?;
self.execution_cache
.clear_state_end_of_epoch(&execution_lock);
self.check_system_consistency(
cur_epoch_store,
checkpoint_executor,
Expand All @@ -2777,7 +2770,6 @@ impl AuthorityState {
.epoch_start_state()
.protocol_version(),
);
self.clear_object_per_epoch_marker_table(&execution_lock)?;
self.execution_cache
.set_epoch_start_configuration(&epoch_start_configuration)?;
if let Some(checkpoint_path) = &self.db_checkpoint_config.checkpoint_path {
Expand Down
5 changes: 4 additions & 1 deletion crates/sui-core/src/authority/test_authority_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ impl<'a> TestAuthorityBuilder<'a> {
None => ExpensiveSafetyCheckConfig::default(),
Some(config) => config,
};
let cache = Arc::new(ExecutionCache::new(authority_store.clone(), &registry));
let cache = Arc::new(ExecutionCache::new_for_tests(
authority_store.clone(),
&registry,
));
let epoch_store = AuthorityPerEpochStore::new(
name,
Arc::new(genesis_committee.clone()),
Expand Down
Loading

0 comments on commit 09c9759

Please sign in to comment.