From 59dbfc282623a23c1ebae57c69aad9de2027e27a Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 21 Jul 2024 08:57:04 -0400 Subject: [PATCH] flatten module hierarchy --- src/accumulator.rs | 2 +- src/{runtime => }/active_query.rs | 0 src/function.rs | 2 +- src/function/backdate.rs | 2 +- src/function/delete.rs | 2 +- src/function/diff_outputs.rs | 4 ++-- src/function/execute.rs | 5 ++--- src/function/inputs.rs | 2 +- src/function/maybe_changed_after.rs | 6 ++---- src/function/memo.rs | 6 +++--- src/function/specify.rs | 2 +- src/function/store.rs | 2 +- src/ingredient.rs | 4 ++-- src/input.rs | 3 ++- src/input/input_field.rs | 2 +- src/interned.rs | 2 +- src/lib.rs | 2 ++ src/{runtime => }/local_state.rs | 7 +++---- src/runtime.rs | 10 +++------- src/runtime/dependency_graph.rs | 4 ++-- src/tracked_struct.rs | 3 ++- src/tracked_struct/tracked_field.rs | 2 +- 22 files changed, 35 insertions(+), 39 deletions(-) rename src/{runtime => }/active_query.rs (100%) rename src/{runtime => }/local_state.rs (99%) diff --git a/src/accumulator.rs b/src/accumulator.rs index bb961b99..12034c65 100644 --- a/src/accumulator.rs +++ b/src/accumulator.rs @@ -10,7 +10,7 @@ use crate::{ hash::FxDashMap, ingredient::{fmt_index, Ingredient, Jar}, key::DependencyIndex, - runtime::local_state::QueryOrigin, + local_state::QueryOrigin, storage::IngredientIndex, Database, DatabaseKeyIndex, Event, EventKind, Id, Revision, Runtime, }; diff --git a/src/runtime/active_query.rs b/src/active_query.rs similarity index 100% rename from src/runtime/active_query.rs rename to src/active_query.rs diff --git a/src/function.rs b/src/function.rs index 4633bcd0..4b3fb55e 100644 --- a/src/function.rs +++ b/src/function.rs @@ -6,7 +6,7 @@ use crate::{ cycle::CycleRecoveryStrategy, ingredient::fmt_index, key::DatabaseKeyIndex, - runtime::local_state::QueryOrigin, + local_state::QueryOrigin, salsa_struct::SalsaStructInDb, storage::{DatabaseGen, IngredientIndex}, Cycle, Database, Event, EventKind, Id, Revision, diff --git a/src/function/backdate.rs b/src/function/backdate.rs index 65709d07..64fa0caf 100644 --- a/src/function/backdate.rs +++ b/src/function/backdate.rs @@ -1,4 +1,4 @@ -use crate::runtime::local_state::QueryRevisions; +use crate::local_state::QueryRevisions; use super::{memo::Memo, Configuration, IngredientImpl}; diff --git a/src/function/delete.rs b/src/function/delete.rs index 3a5ccca8..8c1dc6f2 100644 --- a/src/function/delete.rs +++ b/src/function/delete.rs @@ -1,7 +1,7 @@ use arc_swap::ArcSwap; use crossbeam::queue::SegQueue; -use crate::{runtime::local_state::QueryOrigin, Id}; +use crate::{local_state::QueryOrigin, Id}; use super::{memo, Configuration, IngredientImpl}; diff --git a/src/function/diff_outputs.rs b/src/function/diff_outputs.rs index ba148743..ab647d1a 100644 --- a/src/function/diff_outputs.rs +++ b/src/function/diff_outputs.rs @@ -1,6 +1,6 @@ use crate::{ - hash::FxHashSet, key::DependencyIndex, runtime::local_state::QueryRevisions, - storage::DatabaseGen, Database, DatabaseKeyIndex, Event, EventKind, + hash::FxHashSet, key::DependencyIndex, local_state::QueryRevisions, storage::DatabaseGen, + Database, DatabaseKeyIndex, Event, EventKind, }; use super::{memo::Memo, Configuration, IngredientImpl}; diff --git a/src/function/execute.rs b/src/function/execute.rs index 06b33ff3..02031a79 100644 --- a/src/function/execute.rs +++ b/src/function/execute.rs @@ -1,9 +1,8 @@ use std::sync::Arc; use crate::{ - runtime::{local_state::ActiveQueryGuard, StampedValue}, - storage::DatabaseGen, - Cycle, Database, Event, EventKind, + local_state::ActiveQueryGuard, runtime::StampedValue, storage::DatabaseGen, Cycle, Database, + Event, EventKind, }; use super::{memo::Memo, Configuration, IngredientImpl}; diff --git a/src/function/inputs.rs b/src/function/inputs.rs index 1b284003..ae54ca7e 100644 --- a/src/function/inputs.rs +++ b/src/function/inputs.rs @@ -1,4 +1,4 @@ -use crate::{runtime::local_state::QueryOrigin, Id}; +use crate::{local_state::QueryOrigin, Id}; use super::{Configuration, IngredientImpl}; diff --git a/src/function/maybe_changed_after.rs b/src/function/maybe_changed_after.rs index c980f4b3..f838d74a 100644 --- a/src/function/maybe_changed_after.rs +++ b/src/function/maybe_changed_after.rs @@ -2,10 +2,8 @@ use arc_swap::Guard; use crate::{ key::DatabaseKeyIndex, - runtime::{ - local_state::{ActiveQueryGuard, EdgeKind, QueryOrigin}, - StampedValue, - }, + local_state::{ActiveQueryGuard, EdgeKind, QueryOrigin}, + runtime::StampedValue, storage::DatabaseGen, Id, Revision, Runtime, }; diff --git a/src/function/memo.rs b/src/function/memo.rs index ec41210d..2b93f78a 100644 --- a/src/function/memo.rs +++ b/src/function/memo.rs @@ -4,8 +4,8 @@ use arc_swap::{ArcSwap, Guard}; use crossbeam::atomic::AtomicCell; use crate::{ - hash::FxDashMap, key::DatabaseKeyIndex, runtime::local_state::QueryRevisions, Event, EventKind, - Id, Revision, Runtime, + hash::FxDashMap, key::DatabaseKeyIndex, local_state::QueryRevisions, Event, EventKind, Id, + Revision, Runtime, }; use super::Configuration; @@ -78,7 +78,7 @@ impl MemoMap { /// with an equivalent memo that has no value. If the memo is untracked, BaseInput, /// or has values assigned as output of another query, this has no effect. pub(super) fn evict(&self, key: Id) { - use crate::runtime::local_state::QueryOrigin; + use crate::local_state::QueryOrigin; use dashmap::mapref::entry::Entry::*; if let Occupied(entry) = self.map.entry(key) { diff --git a/src/function/specify.rs b/src/function/specify.rs index 95abb1f2..a0664034 100644 --- a/src/function/specify.rs +++ b/src/function/specify.rs @@ -1,7 +1,7 @@ use crossbeam::atomic::AtomicCell; use crate::{ - runtime::local_state::{QueryOrigin, QueryRevisions}, + local_state::{QueryOrigin, QueryRevisions}, storage::DatabaseGen, tracked_struct::TrackedStructInDb, Database, DatabaseKeyIndex, Id, diff --git a/src/function/store.rs b/src/function/store.rs index 008120ba..aefe1c48 100644 --- a/src/function/store.rs +++ b/src/function/store.rs @@ -4,7 +4,7 @@ use crossbeam::atomic::AtomicCell; use crate::{ durability::Durability, - runtime::local_state::{QueryOrigin, QueryRevisions}, + local_state::{QueryOrigin, QueryRevisions}, Id, Runtime, }; diff --git a/src/ingredient.rs b/src/ingredient.rs index 4751816a..f06355df 100644 --- a/src/ingredient.rs +++ b/src/ingredient.rs @@ -4,8 +4,8 @@ use std::{ }; use crate::{ - cycle::CycleRecoveryStrategy, runtime::local_state::QueryOrigin, storage::IngredientIndex, - Database, DatabaseKeyIndex, Id, + cycle::CycleRecoveryStrategy, local_state::QueryOrigin, storage::IngredientIndex, Database, + DatabaseKeyIndex, Id, }; use super::Revision; diff --git a/src/input.rs b/src/input.rs index 2fd24814..e3246d7c 100644 --- a/src/input.rs +++ b/src/input.rs @@ -17,8 +17,9 @@ use crate::{ id::{AsId, FromId}, ingredient::{fmt_index, Ingredient}, key::{DatabaseKeyIndex, DependencyIndex}, + local_state::QueryOrigin, plumbing::{Jar, Stamp}, - runtime::{local_state::QueryOrigin, Runtime}, + runtime::Runtime, storage::IngredientIndex, Database, Durability, Id, Revision, }; diff --git a/src/input/input_field.rs b/src/input/input_field.rs index fccd1ca3..75b8505c 100644 --- a/src/input/input_field.rs +++ b/src/input/input_field.rs @@ -1,7 +1,7 @@ use crate::cycle::CycleRecoveryStrategy; use crate::ingredient::{fmt_index, Ingredient}; use crate::input::Configuration; -use crate::runtime::local_state::QueryOrigin; +use crate::local_state::QueryOrigin; use crate::storage::IngredientIndex; use crate::{Database, DatabaseKeyIndex, Id, Revision}; use std::fmt; diff --git a/src/interned.rs b/src/interned.rs index b9a6912b..1715b846 100644 --- a/src/interned.rs +++ b/src/interned.rs @@ -9,8 +9,8 @@ use crate::durability::Durability; use crate::id::AsId; use crate::ingredient::fmt_index; use crate::key::DependencyIndex; +use crate::local_state::QueryOrigin; use crate::plumbing::Jar; -use crate::runtime::local_state::QueryOrigin; use crate::runtime::Runtime; use crate::storage::IngredientIndex; use crate::{Database, DatabaseKeyIndex, Id}; diff --git a/src/lib.rs b/src/lib.rs index a68dd73c..88700b2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ mod accumulator; +mod active_query; mod alloc; mod array; mod cancelled; @@ -15,6 +16,7 @@ mod ingredient_list; mod input; mod interned; mod key; +mod local_state; mod nonce; mod revision; mod runtime; diff --git a/src/runtime/local_state.rs b/src/local_state.rs similarity index 99% rename from src/runtime/local_state.rs rename to src/local_state.rs index 53076a1e..decb3db1 100644 --- a/src/runtime/local_state.rs +++ b/src/local_state.rs @@ -1,18 +1,17 @@ use tracing::debug; +use super::active_query::ActiveQuery; use crate::durability::Durability; use crate::key::DatabaseKeyIndex; use crate::key::DependencyIndex; -use crate::runtime::Revision; +use crate::runtime::StampedValue; use crate::tracked_struct::Disambiguator; use crate::Cycle; +use crate::Revision; use crate::Runtime; use std::cell::RefCell; use std::sync::Arc; -use super::active_query::ActiveQuery; -use super::StampedValue; - /// State that is specific to a single execution thread. /// /// Internally, this type uses ref-cells. diff --git a/src/runtime.rs b/src/runtime.rs index 36213b9b..7266d7b9 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -7,25 +7,21 @@ use crossbeam::atomic::AtomicCell; use parking_lot::Mutex; use crate::{ + active_query::ActiveQuery, cycle::CycleRecoveryStrategy, durability::Durability, key::{DatabaseKeyIndex, DependencyIndex}, + local_state::{self, ActiveQueryGuard, EdgeKind}, revision::AtomicRevision, - runtime::active_query::ActiveQuery, storage::IngredientIndex, Cancelled, Cycle, Database, Event, EventKind, Revision, }; -use self::{ - dependency_graph::DependencyGraph, - local_state::{ActiveQueryGuard, EdgeKind}, -}; +use self::dependency_graph::DependencyGraph; use super::tracked_struct::Disambiguator; -mod active_query; mod dependency_graph; -pub mod local_state; pub struct Runtime { /// Our unique runtime id. diff --git a/src/runtime/dependency_graph.rs b/src/runtime/dependency_graph.rs index 85a0460f..766356c5 100644 --- a/src/runtime/dependency_graph.rs +++ b/src/runtime/dependency_graph.rs @@ -1,12 +1,12 @@ use std::sync::Arc; +use crate::active_query::ActiveQuery; use crate::key::DatabaseKeyIndex; +use crate::runtime::{RuntimeId, WaitResult}; use parking_lot::{Condvar, MutexGuard}; use rustc_hash::FxHashMap; use smallvec::SmallVec; -use super::{active_query::ActiveQuery, RuntimeId, WaitResult}; - type QueryStack = Vec; #[derive(Debug, Default)] diff --git a/src/tracked_struct.rs b/src/tracked_struct.rs index 46423a88..e6c789eb 100644 --- a/src/tracked_struct.rs +++ b/src/tracked_struct.rs @@ -11,7 +11,8 @@ use crate::{ ingredient::{fmt_index, Ingredient, Jar}, ingredient_list::IngredientList, key::{DatabaseKeyIndex, DependencyIndex}, - runtime::{local_state::QueryOrigin, Runtime}, + local_state::QueryOrigin, + runtime::Runtime, salsa_struct::SalsaStructInDb, storage::IngredientIndex, Database, Durability, Event, Id, Revision, diff --git a/src/tracked_struct/tracked_field.rs b/src/tracked_struct/tracked_field.rs index 86bf94d9..5c62df2d 100644 --- a/src/tracked_struct/tracked_field.rs +++ b/src/tracked_struct/tracked_field.rs @@ -90,7 +90,7 @@ where field_changed_at > revision } - fn origin(&self, _key_index: crate::Id) -> Option { + fn origin(&self, _key_index: crate::Id) -> Option { None }