Repository: salsa-rs/salsa (rust)

Issue:
Add an API to mock some input of durability has changed.
`synthetic_write` in old salsa causes the system to act *as though* some  input of durability `durability` has changed. Maybe we should support it in salsa-2022 too. 
https://github.com/salsa-rs/salsa/blob/80d0d141945051ec86ecd979ac06cca1e364b27e/src/runtime.rs#L100-L110  


Pull request:
add `synthetic_write`
fixes #364 

add `synthetic_write` and use it in test `lru_keeps_dependency_info`, the test will now be broken. We can use `lru_keeps_dependency_info` as a test for https://github.com/salsa-rs/salsa/issues/365, which already has a pr https://github.com/salsa-rs/salsa/pull/371.

Patch:
diff --git a/calc-example/calc/src/db.rs b/calc-example/calc/src/db.rs
index 286eaa34..83638028 100644
--- a/calc-example/calc/src/db.rs
+++ b/calc-example/calc/src/db.rs
@@ -47,10 +47,6 @@ impl Default for Database {
 
 // ANCHOR: db_impl
 impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-
     fn salsa_event(&self, event: salsa::Event) {
         // Log interesting events, if logging is enabled
         if let Some(logs) = &self.logs {
diff --git a/components/salsa-2022-macros/src/db.rs b/components/salsa-2022-macros/src/db.rs
index fabb706e..6c77ef62 100644
--- a/components/salsa-2022-macros/src/db.rs
+++ b/components/salsa-2022-macros/src/db.rs
@@ -120,6 +120,10 @@ fn has_jars_dyn_impl(input: &syn::ItemStruct, storage: &syn::Ident) -> syn::Item
                 self.#storage.runtime()
             }
 
+            fn runtime_mut(&mut self) ->&mut salsa::Runtime {
+                self.#storage.runtime_mut()
+            }
+
             fn maybe_changed_after(
                 &self,
                 input: salsa::key::DependencyIndex,
@@ -159,6 +163,7 @@ fn has_jars_dyn_impl(input: &syn::ItemStruct, storage: &syn::Ident) -> syn::Item
                 let ingredient = self.#storage.ingredient(ingredient);
                 ingredient.salsa_struct_deleted(self, id);
             }
+
             fn fmt_index(&self, index: salsa::key::DependencyIndex, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
                 let ingredient = self.#storage.ingredient(index.ingredient_index());
                 ingredient.fmt_index(index.key_index(), fmt)
diff --git a/components/salsa-2022/src/accumulator.rs b/components/salsa-2022/src/accumulator.rs
index fcae3d05..2274a378 100644
--- a/components/salsa-2022/src/accumulator.rs
+++ b/components/salsa-2022/src/accumulator.rs
@@ -120,7 +120,7 @@ where
         output_key: Option<crate::Id>,
     ) {
         assert!(output_key.is_none());
-        let current_revision = db.salsa_runtime().current_revision();
+        let current_revision = db.runtime().current_revision();
         if let Some(mut v) = self.map.get_mut(&executor) {
             // The value is still valid in the new revision.
             v.produced_at = current_revision;
@@ -136,7 +136,7 @@ where
         assert!(stale_output_key.is_none());
         if self.map.remove(&executor).is_some() {
             db.salsa_event(Event {
-                runtime_id: db.salsa_runtime().id(),
+                runtime_id: db.runtime().id(),
                 kind: EventKind::DidDiscardAccumulated {
                     executor_key: executor,
                     accumulator: self.dependency_index(),
diff --git a/components/salsa-2022/src/database.rs b/components/salsa-2022/src/database.rs
index 15104844..64599196 100644
--- a/components/salsa-2022/src/database.rs
+++ b/components/salsa-2022/src/database.rs
@@ -1,4 +1,4 @@
-use crate::{storage::HasJarsDyn, DebugWithDb, Event, Runtime};
+use crate::{storage::HasJarsDyn, DebugWithDb, Durability, Event};
 
 pub trait Database: HasJarsDyn + AsSalsaDatabase {
     /// This function is invoked at key points in the salsa
@@ -11,7 +11,25 @@ pub trait Database: HasJarsDyn + AsSalsaDatabase {
         log::debug!("salsa_event: {:?}", event.debug(self));
     }
 
-    fn salsa_runtime(&self) -> &Runtime;
+    /// A "synthetic write" causes the system to act *as though* some
+    /// input of durability `durability` has changed. This is mostly
+    /// useful for profiling scenarios.
+    ///
+    /// **WARNING:** Just like an ordinary write, this method triggers
+    /// cancellation. If you invoke it while a snapshot exists, it
+    /// will block until that snapshot is dropped -- if that snapshot
+    /// is owned by the current thread, this could trigger deadlock.
+    fn synthetic_write(&mut self, durability: Durability) {
+        self.runtime_mut().report_tracked_write(durability);
+    }
+
+    /// Reports that the query depends on some state unknown to salsa.
+    ///
+    /// Queries which report untracked reads will be re-executed in the next
+    /// revision.
+    fn report_untracked_read(&self) {
+        self.runtime().report_untracked_read();
+    }
 }
 
 /// Indicates a database that also supports parallel query
diff --git a/components/salsa-2022/src/event.rs b/components/salsa-2022/src/event.rs
index 01376646..fdbef715 100644
--- a/components/salsa-2022/src/event.rs
+++ b/components/salsa-2022/src/event.rs
@@ -56,7 +56,7 @@ pub enum EventKind {
     /// before they have answered us.
     ///
     /// (NB: you can find the `id` of the current thread via the
-    /// `salsa_runtime`)
+    /// `runtime`)
     WillBlockOn {
         /// The id of the runtime we will block on.
         other_runtime_id: RuntimeId,
diff --git a/components/salsa-2022/src/function.rs b/components/salsa-2022/src/function.rs
index f88187b7..3123c639 100644
--- a/components/salsa-2022/src/function.rs
+++ b/components/salsa-2022/src/function.rs
@@ -261,7 +261,7 @@ where
         if let Some(origin) = self.delete_memo(id) {
             let key = self.database_key_index(id);
             db.salsa_event(Event {
-                runtime_id: db.salsa_runtime().id(),
+                runtime_id: db.runtime().id(),
                 kind: EventKind::DidDiscard { key },
             });
 
diff --git a/components/salsa-2022/src/function/accumulated.rs b/components/salsa-2022/src/function/accumulated.rs
index df3effc9..58ef6ee5 100644
--- a/components/salsa-2022/src/function/accumulated.rs
+++ b/components/salsa-2022/src/function/accumulated.rs
@@ -3,7 +3,7 @@ use crate::{
     key::DependencyIndex,
     runtime::local_state::QueryOrigin,
     storage::{HasJar, HasJarsDyn},
-    Database, DatabaseKeyIndex,
+    DatabaseKeyIndex,
 };
 
 use super::{Configuration, DynDb, FunctionIngredient};
@@ -26,7 +26,7 @@ where
         // Now walk over all the things that the value depended on
         // and find the values they accumulated into the given
         // accumulator:
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
         let mut result = vec![];
         let accumulator_ingredient = A::accumulator_ingredient(db);
         let mut stack = Stack::new(self.database_key_index(key));
diff --git a/components/salsa-2022/src/function/diff_outputs.rs b/components/salsa-2022/src/function/diff_outputs.rs
index cb989fe3..73e3b09c 100644
--- a/components/salsa-2022/src/function/diff_outputs.rs
+++ b/components/salsa-2022/src/function/diff_outputs.rs
@@ -45,7 +45,7 @@ where
     }
 
     fn report_stale_output(db: &DynDb<'_, C>, key: DatabaseKeyIndex, output: DependencyIndex) {
-        let runtime_id = db.salsa_runtime().id();
+        let runtime_id = db.runtime().id();
         db.salsa_event(Event {
             runtime_id,
             kind: EventKind::WillDiscardStaleOutput {
diff --git a/components/salsa-2022/src/function/execute.rs b/components/salsa-2022/src/function/execute.rs
index a70b7d65..c0735985 100644
--- a/components/salsa-2022/src/function/execute.rs
+++ b/components/salsa-2022/src/function/execute.rs
@@ -3,6 +3,7 @@ use std::sync::Arc;
 use crate::{
     debug::DebugWithDb,
     runtime::{local_state::ActiveQueryGuard, StampedValue},
+    storage::HasJarsDyn,
     Cycle, Database, Event, EventKind,
 };
 
@@ -27,7 +28,7 @@ where
         active_query: ActiveQueryGuard<'_>,
         opt_old_memo: Option<Arc<Memo<C::Value>>>,
     ) -> StampedValue<&C::Value> {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
         let revision_now = runtime.current_revision();
         let database_key_index = active_query.database_key_index;
 
diff --git a/components/salsa-2022/src/function/fetch.rs b/components/salsa-2022/src/function/fetch.rs
index 1bbda7a5..384b3816 100644
--- a/components/salsa-2022/src/function/fetch.rs
+++ b/components/salsa-2022/src/function/fetch.rs
@@ -1,6 +1,6 @@
 use arc_swap::Guard;
 
-use crate::{database::AsSalsaDatabase, runtime::StampedValue, AsId, Database};
+use crate::{database::AsSalsaDatabase, runtime::StampedValue, storage::HasJarsDyn, AsId};
 
 use super::{Configuration, DynDb, FunctionIngredient};
 
@@ -9,7 +9,7 @@ where
     C: Configuration,
 {
     pub fn fetch(&self, db: &DynDb<C>, key: C::Key) -> &C::Value {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
 
         runtime.unwind_if_revision_cancelled(db);
 
@@ -23,7 +23,7 @@ where
             self.evict(AsId::from_id(evicted));
         }
 
-        db.salsa_runtime().report_tracked_read(
+        db.runtime().report_tracked_read(
             self.database_key_index(key).into(),
             durability,
             changed_at,
@@ -46,7 +46,7 @@ where
         let memo_guard = self.memo_map.get(key);
         if let Some(memo) = &memo_guard {
             if memo.value.is_some() {
-                let runtime = db.salsa_runtime();
+                let runtime = db.runtime();
                 if self.shallow_verify_memo(db, runtime, self.database_key_index(key), memo) {
                     let value = unsafe {
                         // Unsafety invariant: memo is present in memo_map
@@ -60,7 +60,7 @@ where
     }
 
     fn fetch_cold(&self, db: &DynDb<C>, key: C::Key) -> Option<StampedValue<&C::Value>> {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
         let database_key_index = self.database_key_index(key);
 
         // Try to claim this query: if someone else has claimed it already, go back and start again.
diff --git a/components/salsa-2022/src/function/maybe_changed_after.rs b/components/salsa-2022/src/function/maybe_changed_after.rs
index 9f64e1da..2888b451 100644
--- a/components/salsa-2022/src/function/maybe_changed_after.rs
+++ b/components/salsa-2022/src/function/maybe_changed_after.rs
@@ -9,7 +9,7 @@ use crate::{
         StampedValue,
     },
     storage::HasJarsDyn,
-    Database, Revision, Runtime,
+    Revision, Runtime,
 };
 
 use super::{memo::Memo, Configuration, DynDb, FunctionIngredient};
@@ -24,7 +24,7 @@ where
         key: C::Key,
         revision: Revision,
     ) -> bool {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
         runtime.unwind_if_revision_cancelled(db);
 
         loop {
@@ -61,7 +61,7 @@ where
         key_index: C::Key,
         revision: Revision,
     ) -> Option<bool> {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
         let database_key_index = self.database_key_index(key_index);
 
         let _claim_guard = self
@@ -148,7 +148,7 @@ where
         old_memo: &Memo<C::Value>,
         active_query: &ActiveQueryGuard<'_>,
     ) -> bool {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
         let database_key_index = active_query.database_key_index;
 
         log::debug!(
diff --git a/components/salsa-2022/src/function/specify.rs b/components/salsa-2022/src/function/specify.rs
index 1769b00c..6de87adf 100644
--- a/components/salsa-2022/src/function/specify.rs
+++ b/components/salsa-2022/src/function/specify.rs
@@ -3,8 +3,9 @@ use crossbeam::atomic::AtomicCell;
 use crate::{
     database::AsSalsaDatabase,
     runtime::local_state::{QueryOrigin, QueryRevisions},
+    storage::HasJarsDyn,
     tracked_struct::TrackedStructInDb,
-    Database, DatabaseKeyIndex, DebugWithDb,
+    DatabaseKeyIndex, DebugWithDb,
 };
 
 use super::{memo::Memo, Configuration, DynDb, FunctionIngredient};
@@ -25,7 +26,7 @@ where
     ) where
         C::Key: TrackedStructInDb<DynDb<'db, C>>,
     {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
 
         let (active_query_key, current_deps) = match runtime.active_query() {
             Some(v) => v,
@@ -101,7 +102,7 @@ where
 
         // Record that the current query *specified* a value for this cell.
         let database_key_index = self.database_key_index(key);
-        db.salsa_runtime().add_output(database_key_index.into());
+        db.runtime().add_output(database_key_index.into());
     }
 
     /// Invoked when the query `executor` has been validated as having green inputs
@@ -114,7 +115,7 @@ where
         executor: DatabaseKeyIndex,
         key: C::Key,
     ) {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
 
         let memo = match self.memo_map.get(key) {
             Some(m) => m,
diff --git a/components/salsa-2022/src/function/sync.rs b/components/salsa-2022/src/function/sync.rs
index e3a8e7b1..aa63e3d8 100644
--- a/components/salsa-2022/src/function/sync.rs
+++ b/components/salsa-2022/src/function/sync.rs
@@ -26,7 +26,7 @@ impl SyncMap {
         db: &'me dyn Database,
         database_key_index: DatabaseKeyIndex,
     ) -> Option<ClaimGuard<'me>> {
-        let runtime = db.salsa_runtime();
+        let runtime = db.runtime();
         match self.sync_map.entry(database_key_index.key_index) {
             dashmap::mapref::entry::Entry::Vacant(entry) => {
                 entry.insert(SyncState {
diff --git a/components/salsa-2022/src/storage.rs b/components/salsa-2022/src/storage.rs
index 83e3d617..4d47aee0 100644
--- a/components/salsa-2022/src/storage.rs
+++ b/components/salsa-2022/src/storage.rs
@@ -93,6 +93,10 @@ where
         &self.runtime
     }
 
+    pub fn runtime_mut(&mut self) -> &mut Runtime {
+        self.jars_mut().1
+    }
+
     // ANCHOR: jars_mut
     /// Gets mutable access to the jars. This will trigger a new revision
     /// and it will also cancel any ongoing work in the current revision.
@@ -199,6 +203,8 @@ pub trait HasJar<J> {
 pub trait HasJarsDyn {
     fn runtime(&self) -> &Runtime;
 
+    fn runtime_mut(&mut self) -> &mut Runtime;
+
     fn maybe_changed_after(&self, input: DependencyIndex, revision: Revision) -> bool;
 
     fn cycle_recovery_strategy(&self, input: IngredientIndex) -> CycleRecoveryStrategy;
diff --git a/components/salsa-2022/src/tracked_struct.rs b/components/salsa-2022/src/tracked_struct.rs
index 9f749097..f66d1f62 100644
--- a/components/salsa-2022/src/tracked_struct.rs
+++ b/components/salsa-2022/src/tracked_struct.rs
@@ -111,7 +111,7 @@ where
     /// discussion and important considerations.
     pub(crate) fn delete_entity(&self, db: &dyn crate::Database, id: Id) {
         db.salsa_event(Event {
-            runtime_id: db.salsa_runtime().id(),
+            runtime_id: db.runtime().id(),
             kind: crate::EventKind::DidDiscard {
                 key: self.database_key_index(id),
             },


Test patch:
diff --git a/salsa-2022-tests/tests/accumulate-from-tracked-fn.rs b/salsa-2022-tests/tests/accumulate-from-tracked-fn.rs
index 92c832b5..e21aa06e 100644
--- a/salsa-2022-tests/tests/accumulate-from-tracked-fn.rs
+++ b/salsa-2022-tests/tests/accumulate-from-tracked-fn.rs
@@ -51,10 +51,6 @@ struct Database {
 
 impl salsa::Database for Database {
     fn salsa_event(&self, _event: salsa::Event) {}
-
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
 }
 
 impl Db for Database {}
diff --git a/salsa-2022-tests/tests/accumulate-reuse-workaround.rs b/salsa-2022-tests/tests/accumulate-reuse-workaround.rs
index 6a1421dc..0b0a33c5 100644
--- a/salsa-2022-tests/tests/accumulate-reuse-workaround.rs
+++ b/salsa-2022-tests/tests/accumulate-reuse-workaround.rs
@@ -55,10 +55,6 @@ struct Database {
 
 impl salsa::Database for Database {
     fn salsa_event(&self, _event: salsa::Event) {}
-
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
 }
 
 impl Db for Database {}
diff --git a/salsa-2022-tests/tests/accumulate-reuse.rs b/salsa-2022-tests/tests/accumulate-reuse.rs
index a2fc5cda..529077ca 100644
--- a/salsa-2022-tests/tests/accumulate-reuse.rs
+++ b/salsa-2022-tests/tests/accumulate-reuse.rs
@@ -50,10 +50,6 @@ struct Database {
 
 impl salsa::Database for Database {
     fn salsa_event(&self, _event: salsa::Event) {}
-
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
 }
 
 impl Db for Database {}
diff --git a/salsa-2022-tests/tests/accumulate.rs b/salsa-2022-tests/tests/accumulate.rs
index 257bd802..0dfbd00d 100644
--- a/salsa-2022-tests/tests/accumulate.rs
+++ b/salsa-2022-tests/tests/accumulate.rs
@@ -70,10 +70,6 @@ struct Database {
 
 impl salsa::Database for Database {
     fn salsa_event(&self, _event: salsa::Event) {}
-
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
 }
 
 impl Db for Database {}
diff --git a/salsa-2022-tests/tests/cycles.rs b/salsa-2022-tests/tests/cycles.rs
index 6aeb3ed9..65eca622 100644
--- a/salsa-2022-tests/tests/cycles.rs
+++ b/salsa-2022-tests/tests/cycles.rs
@@ -3,7 +3,6 @@
 use std::panic::{RefUnwindSafe, UnwindSafe};
 
 use expect_test::expect;
-use salsa::storage::HasJarsDyn;
 use salsa::Durability;
 
 // Axes:
@@ -78,14 +77,10 @@ struct Database {
     storage: salsa::Storage<Self>,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
-
 impl Db for Database {}
 
+impl salsa::Database for Database {}
+
 impl RefUnwindSafe for Database {}
 
 #[salsa::input(jar = Jar)]
@@ -103,13 +98,13 @@ fn memoized_b(db: &dyn Db, input: MyInput) {
 
 #[salsa::tracked(jar = Jar)]
 fn volatile_a(db: &dyn Db, input: MyInput) {
-    db.runtime().report_untracked_read();
+    db.report_untracked_read();
     volatile_b(db, input)
 }
 
 #[salsa::tracked(jar = Jar)]
 fn volatile_b(db: &dyn Db, input: MyInput) {
-    db.runtime().report_untracked_read();
+    db.report_untracked_read();
     volatile_a(db, input)
 }
 
diff --git a/salsa-2022-tests/tests/debug.rs b/salsa-2022-tests/tests/debug.rs
index f0b4d1f7..fc8c6ad9 100644
--- a/salsa-2022-tests/tests/debug.rs
+++ b/salsa-2022-tests/tests/debug.rs
@@ -30,11 +30,7 @@ struct Database {
     storage: salsa::Storage<Self>,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/deletion-cascade.rs b/salsa-2022-tests/tests/deletion-cascade.rs
index d9002957..2871b34f 100644
--- a/salsa-2022-tests/tests/deletion-cascade.rs
+++ b/salsa-2022-tests/tests/deletion-cascade.rs
@@ -76,10 +76,6 @@ impl salsa::Database for Database {
             _ => {}
         }
     }
-
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
 }
 
 impl Db for Database {}
diff --git a/salsa-2022-tests/tests/deletion.rs b/salsa-2022-tests/tests/deletion.rs
index fdd453f8..d4b6be51 100644
--- a/salsa-2022-tests/tests/deletion.rs
+++ b/salsa-2022-tests/tests/deletion.rs
@@ -69,10 +69,6 @@ impl salsa::Database for Database {
             _ => {}
         }
     }
-
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
 }
 
 impl Db for Database {}
diff --git a/salsa-2022-tests/tests/expect_reuse_field_x_of_a_tracked_struct_changes_but_fn_depends_on_field_y.rs b/salsa-2022-tests/tests/expect_reuse_field_x_of_a_tracked_struct_changes_but_fn_depends_on_field_y.rs
index e4185c7d..6d5fbfb8 100644
--- a/salsa-2022-tests/tests/expect_reuse_field_x_of_a_tracked_struct_changes_but_fn_depends_on_field_y.rs
+++ b/salsa-2022-tests/tests/expect_reuse_field_x_of_a_tracked_struct_changes_but_fn_depends_on_field_y.rs
@@ -53,11 +53,7 @@ struct Database {
     logger: Logger,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/expect_reuse_field_x_of_an_input_changes_but_fn_depends_on_field_y.rs b/salsa-2022-tests/tests/expect_reuse_field_x_of_an_input_changes_but_fn_depends_on_field_y.rs
index 5de3b98e..24beb223 100644
--- a/salsa-2022-tests/tests/expect_reuse_field_x_of_an_input_changes_but_fn_depends_on_field_y.rs
+++ b/salsa-2022-tests/tests/expect_reuse_field_x_of_an_input_changes_but_fn_depends_on_field_y.rs
@@ -37,11 +37,7 @@ struct Database {
     logger: Logger,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/hello_world.rs b/salsa-2022-tests/tests/hello_world.rs
index 99d53940..88ccd835 100644
--- a/salsa-2022-tests/tests/hello_world.rs
+++ b/salsa-2022-tests/tests/hello_world.rs
@@ -40,11 +40,7 @@ struct Database {
     logger: Logger,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/lru.rs b/salsa-2022-tests/tests/lru.rs
index bbb041b3..9426677a 100644
--- a/salsa-2022-tests/tests/lru.rs
+++ b/salsa-2022-tests/tests/lru.rs
@@ -6,6 +6,7 @@ use std::sync::{
     Arc,
 };
 
+use salsa::Database;
 use salsa_2022_tests::{HasLogger, Logger};
 use test_log::test;
 
@@ -54,26 +55,22 @@ fn get_hot_potato2(db: &dyn Db, input: MyInput) -> u32 {
 #[salsa::tracked(jar = Jar, lru = 32)]
 fn get_volatile(db: &dyn Db, _input: MyInput) -> usize {
     static COUNTER: AtomicUsize = AtomicUsize::new(0);
-    db.salsa_runtime().report_untracked_read();
+    db.report_untracked_read();
     COUNTER.fetch_add(1, Ordering::SeqCst)
 }
 
 #[salsa::db(Jar)]
 #[derive(Default)]
-struct Database {
+struct DatabaseImpl {
     storage: salsa::Storage<Self>,
     logger: Logger,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for DatabaseImpl {}
 
-impl Db for Database {}
+impl Db for DatabaseImpl {}
 
-impl HasLogger for Database {
+impl HasLogger for DatabaseImpl {
     fn logger(&self) -> &Logger {
         &self.logger
     }
@@ -85,7 +82,7 @@ fn load_n_potatoes() -> usize {
 
 #[test]
 fn lru_works() {
-    let mut db = Database::default();
+    let mut db = DatabaseImpl::default();
     assert_eq!(load_n_potatoes(), 0);
 
     for i in 0..128u32 {
@@ -101,7 +98,7 @@ fn lru_works() {
 
 #[test]
 fn lru_doesnt_break_volatile_queries() {
-    let mut db = Database::default();
+    let mut db = DatabaseImpl::default();
 
     // Create all inputs first, so that there are no revision changes among calls to `get_volatile`
     let inputs: Vec<MyInput> = (0..128usize)
@@ -121,7 +118,7 @@ fn lru_doesnt_break_volatile_queries() {
 
 #[test]
 fn lru_can_be_changed_at_runtime() {
-    let mut db = Database::default();
+    let mut db = DatabaseImpl::default();
     assert_eq!(load_n_potatoes(), 0);
 
     let inputs: Vec<(u32, MyInput)> = (0..128).map(|i| (i, MyInput::new(&mut db, i))).collect();
@@ -164,7 +161,7 @@ fn lru_can_be_changed_at_runtime() {
 
 #[test]
 fn lru_keeps_dependency_info() {
-    let mut db = Database::default();
+    let mut db = DatabaseImpl::default();
     let capacity = 32;
 
     // Invoke `get_hot_potato2` 33 times. This will (in turn) invoke
@@ -178,6 +175,8 @@ fn lru_keeps_dependency_info() {
         assert_eq!(x as usize, i);
     }
 
+    db.synthetic_write(salsa::Durability::HIGH);
+
     // We want to test that calls to `get_hot_potato2` are still considered
     // clean. Check that no new executions occur as we go here.
     db.assert_logs_len((capacity + 1) * 2);
diff --git a/salsa-2022-tests/tests/mutate_in_place.rs b/salsa-2022-tests/tests/mutate_in_place.rs
index b6330345..645f553a 100644
--- a/salsa-2022-tests/tests/mutate_in_place.rs
+++ b/salsa-2022-tests/tests/mutate_in_place.rs
@@ -22,11 +22,7 @@ struct Database {
     logger: Logger,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/override_new_get_set.rs b/salsa-2022-tests/tests/override_new_get_set.rs
index 80470e67..10d449a7 100644
--- a/salsa-2022-tests/tests/override_new_get_set.rs
+++ b/salsa-2022-tests/tests/override_new_get_set.rs
@@ -72,11 +72,7 @@ fn execute() {
         storage: salsa::Storage<Self>,
     }
 
-    impl salsa::Database for Database {
-        fn salsa_runtime(&self) -> &salsa::Runtime {
-            self.storage.runtime()
-        }
-    }
+    impl salsa::Database for Database {}
 
     impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/parallel/setup.rs b/salsa-2022-tests/tests/parallel/setup.rs
index 8012928c..f78f30e2 100644
--- a/salsa-2022-tests/tests/parallel/setup.rs
+++ b/salsa-2022-tests/tests/parallel/setup.rs
@@ -38,10 +38,6 @@ pub(crate) struct Database {
 }
 
 impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-
     fn salsa_event(&self, event: salsa::Event) {
         if let salsa::EventKind::WillBlockOn { .. } = event.kind {
             self.signal(self.knobs().signal_on_will_block.get());
diff --git a/salsa-2022-tests/tests/specify_tracked_fn_in_rev_1_but_not_2.rs b/salsa-2022-tests/tests/specify_tracked_fn_in_rev_1_but_not_2.rs
index f1caa1e2..98d3dea6 100644
--- a/salsa-2022-tests/tests/specify_tracked_fn_in_rev_1_but_not_2.rs
+++ b/salsa-2022-tests/tests/specify_tracked_fn_in_rev_1_but_not_2.rs
@@ -72,10 +72,6 @@ struct Database {
 }
 
 impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-
     fn salsa_event(&self, event: salsa::Event) {
         self.push_log(format!("{:?}", event.debug(self)));
     }
diff --git a/salsa-2022-tests/tests/tracked_fn_on_input.rs b/salsa-2022-tests/tests/tracked_fn_on_input.rs
index 9466b0ed..96c4979e 100644
--- a/salsa-2022-tests/tests/tracked_fn_on_input.rs
+++ b/salsa-2022-tests/tests/tracked_fn_on_input.rs
@@ -25,11 +25,7 @@ fn execute() {
         storage: salsa::Storage<Self>,
     }
 
-    impl salsa::Database for Database {
-        fn salsa_runtime(&self) -> &salsa::Runtime {
-            self.storage.runtime()
-        }
-    }
+    impl salsa::Database for Database {}
 
     impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/tracked_fn_on_tracked.rs b/salsa-2022-tests/tests/tracked_fn_on_tracked.rs
index 68d32e30..69571ade 100644
--- a/salsa-2022-tests/tests/tracked_fn_on_tracked.rs
+++ b/salsa-2022-tests/tests/tracked_fn_on_tracked.rs
@@ -27,11 +27,7 @@ struct Database {
     storage: salsa::Storage<Self>,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/tracked_fn_on_tracked_specify.rs b/salsa-2022-tests/tests/tracked_fn_on_tracked_specify.rs
index 57daeb5e..cacc679f 100644
--- a/salsa-2022-tests/tests/tracked_fn_on_tracked_specify.rs
+++ b/salsa-2022-tests/tests/tracked_fn_on_tracked_specify.rs
@@ -37,11 +37,7 @@ struct Database {
     storage: salsa::Storage<Self>,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}
 
diff --git a/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs b/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs
index 6d45a9e2..77f48066 100644
--- a/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs
+++ b/salsa-2022-tests/tests/tracked_fn_read_own_entity.rs
@@ -41,11 +41,7 @@ struct Database {
     logger: Logger,
 }
 
-impl salsa::Database for Database {
-    fn salsa_runtime(&self) -> &salsa::Runtime {
-        self.storage.runtime()
-    }
-}
+impl salsa::Database for Database {}
 
 impl Db for Database {}