remove salsa_runtime

This commit is contained in:
XFFXFF 2022-08-25 06:01:23 +08:00
parent 0e0626abfa
commit 2dc5a6c796
13 changed files with 27 additions and 29 deletions

View file

@ -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(),

View file

@ -1,4 +1,4 @@
use crate::{storage::HasJarsDyn, DebugWithDb, Event, Runtime};
use crate::{storage::HasJarsDyn, DebugWithDb, Event};
pub trait Database: HasJarsDyn + AsSalsaDatabase {
/// This function is invoked at key points in the salsa
@ -10,10 +10,6 @@ pub trait Database: HasJarsDyn + AsSalsaDatabase {
fn salsa_event(&self, event: Event) {
log::debug!("salsa_event: {:?}", event.debug(self));
}
fn salsa_runtime(&self) -> &Runtime {
self.runtime()
}
}
/// Indicates a database that also supports parallel query

View file

@ -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,

View file

@ -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 },
});

View file

@ -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));

View file

@ -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 {

View file

@ -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;

View file

@ -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.

View file

@ -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!(

View file

@ -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,

View file

@ -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 {

View file

@ -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),
},

View file

@ -55,7 +55,7 @@ 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.runtime().report_untracked_read();
COUNTER.fetch_add(1, Ordering::SeqCst)
}