Skip to content

Commit 273e915

Browse files
committed
switch to PCT shuttle scheduler
1 parent 678f51a commit 273e915

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+539
-623
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ jobs:
5252
- name: Format
5353
run: cargo fmt -- --check
5454
- name: Clippy
55-
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
55+
run: cargo clippy --workspace --all-targets -- -D warnings
5656
- name: Test
57-
run: cargo nextest run --workspace --all-features --all-targets --no-fail-fast
57+
run: cargo nextest run --workspace --all-targets --no-fail-fast
5858
- name: Test docs
59-
run: cargo test --workspace --all-features --doc
59+
run: cargo test --workspace --doc
6060
- name: Check (without default features)
6161
run: cargo check --workspace --no-default-features
62-
- name: Check (loom)
63-
run: RUSTFLAGS="--cfg loom" cargo check --workspace --features loom
6462

6563
miri:
6664
name: Miri
@@ -88,12 +86,34 @@ jobs:
8886
- name: Setup Miri
8987
run: cargo miri setup
9088
- name: Test with Miri
91-
run: cargo miri nextest run --all-features --no-fail-fast --tests
89+
run: cargo miri nextest run --no-fail-fast --tests
9290
env:
9391
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-retag-fields
9492
- name: Run examples with Miri
9593
run: cargo miri run --example calc
9694

95+
shuttle:
96+
name: Shuttle
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Checkout
100+
uses: actions/checkout@v4
101+
id: rust-toolchain
102+
- uses: actions/cache@v4
103+
with:
104+
path: |
105+
~/.cargo/bin/
106+
~/.cargo/registry/index/
107+
~/.cargo/registry/cache/
108+
~/.cargo/git/db/
109+
target/
110+
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
111+
restore-keys: |
112+
${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.cachekey }}-
113+
${{ runner.os }}-cargo-
114+
- name: Test with Shuttle
115+
run: cargo test --features shuttle --test parallel
116+
97117
benchmarks:
98118
# https://github.com/CodSpeedHQ/action/issues/126
99119
if: github.event_name != 'merge_group'

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ salsa-macros = { version = "0.21.1", path = "components/salsa-macros", optional
1515
boxcar = { version = "0.2.12" }
1616
crossbeam-queue = "0.3.11"
1717
dashmap = { version = "6", features = ["raw-api"] }
18+
# the version of hashbrown used by dashmap
19+
hashbrown_14 = { version = "0.14", package = "hashbrown" }
1820
hashbrown = "0.15"
1921
hashlink = "0.10"
2022
indexmap = "2"
@@ -30,13 +32,14 @@ rayon = { version = "1.10.0", optional = true }
3032
# Stuff we want Update impls for by default
3133
compact_str = { version = "0.9", optional = true }
3234
thin-vec = "0.2.13"
33-
loom = { version = "0.7.2", optional = true }
35+
36+
shuttle = { version = "0.8.0", optional = true }
3437

3538
[features]
3639
default = ["salsa_unstable", "rayon", "macros"]
40+
shuttle = ["dep:shuttle"]
3741
# FIXME: remove `salsa_unstable` before 1.0.
3842
salsa_unstable = []
39-
loom = ["dep:loom", "boxcar/loom"]
4043
macros = ["dep:salsa-macros"]
4144

4245
# This interlocks the `salsa-macros` and `salsa` versions together
@@ -67,9 +70,6 @@ half = "=2.4.1"
6770
[target.'cfg(all(not(target_os = "windows"), not(target_os = "openbsd"), any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "powerpc64")))'.dev-dependencies]
6871
tikv-jemallocator = "0.6.0"
6972

70-
[lints.rust]
71-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)'] }
72-
7373
[[bench]]
7474
name = "compare"
7575
harness = false

components/salsa-macro-rules/src/setup_accumulator_impl.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ macro_rules! setup_accumulator_impl {
2121
use salsa::plumbing as $zalsa;
2222
use salsa::plumbing::accumulator as $zalsa_struct;
2323

24-
// Suppress the lint against `cfg(loom)`.
25-
#[allow(unexpected_cfgs)]
2624
fn $ingredient(zalsa: &$zalsa::Zalsa) -> &$zalsa_struct::IngredientImpl<$Struct> {
27-
$zalsa::__maybe_lazy_static! {
28-
static $CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Struct>> =
29-
$zalsa::IngredientCache::new();
30-
}
25+
static $CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Struct>> =
26+
$zalsa::IngredientCache::new();
3127

3228
$CACHE.get_or_create(zalsa, || {
3329
zalsa.add_or_lookup_jar_by_type::<$zalsa_struct::JarImpl<$Struct>>()

components/salsa-macro-rules/src/setup_input_struct.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,9 @@ macro_rules! setup_input_struct {
9595
Self::ingredient_(db.zalsa())
9696
}
9797

98-
// Suppress the lint against `cfg(loom)`.
99-
#[allow(unexpected_cfgs)]
10098
fn ingredient_(zalsa: &$zalsa::Zalsa) -> &$zalsa_struct::IngredientImpl<Self> {
101-
zalsa_::__maybe_lazy_static! {
102-
static CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Configuration>> =
103-
$zalsa::IngredientCache::new();
104-
}
99+
static CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Configuration>> =
100+
$zalsa::IngredientCache::new();
105101

106102
CACHE.get_or_create(zalsa, || {
107103
zalsa.add_or_lookup_jar_by_type::<$zalsa_struct::JarImpl<$Configuration>>()

components/salsa-macro-rules/src/setup_interned_struct.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,12 @@ macro_rules! setup_interned_struct {
131131
}
132132

133133
impl $Configuration {
134-
// Suppress the lint against `cfg(loom)`.
135-
#[allow(unexpected_cfgs)]
136134
pub fn ingredient<Db>(db: &Db) -> &$zalsa_struct::IngredientImpl<Self>
137135
where
138136
Db: ?Sized + $zalsa::Database,
139137
{
140-
$zalsa::__maybe_lazy_static! {
141-
static CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Configuration>> =
142-
$zalsa::IngredientCache::new();
143-
}
138+
static CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Configuration>> =
139+
$zalsa::IngredientCache::new();
144140

145141
let zalsa = db.zalsa();
146142
CACHE.get_or_create(zalsa, || {

components/salsa-macro-rules/src/setup_tracked_fn.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ macro_rules! setup_tracked_fn {
7474
) => {
7575
// Suppress this clippy lint because we sometimes require `'db` where the ordinary Rust rules would not.
7676
#[allow(clippy::needless_lifetimes)]
77-
// Suppress the lint against `cfg(loom)`.
78-
#[allow(unexpected_cfgs)]
7977
$(#[$attr])*
8078
$vis fn $fn_name<$db_lt>(
8179
$db: &$db_lt dyn $Db,
@@ -85,10 +83,8 @@ macro_rules! setup_tracked_fn {
8583

8684
struct $Configuration;
8785

88-
$zalsa::__maybe_lazy_static! {
89-
static $FN_CACHE: $zalsa::IngredientCache<$zalsa::function::IngredientImpl<$Configuration>> =
90-
$zalsa::IngredientCache::new();
91-
}
86+
static $FN_CACHE: $zalsa::IngredientCache<$zalsa::function::IngredientImpl<$Configuration>> =
87+
$zalsa::IngredientCache::new();
9288

9389
$zalsa::macro_if! {
9490
if $needs_interner {
@@ -98,10 +94,8 @@ macro_rules! setup_tracked_fn {
9894
std::marker::PhantomData<&$db_lt $zalsa::interned::Value<$Configuration>>,
9995
);
10096

101-
$zalsa::__maybe_lazy_static! {
102-
static $INTERN_CACHE: $zalsa::IngredientCache<$zalsa::interned::IngredientImpl<$Configuration>> =
103-
$zalsa::IngredientCache::new();
104-
}
97+
static $INTERN_CACHE: $zalsa::IngredientCache<$zalsa::interned::IngredientImpl<$Configuration>> =
98+
$zalsa::IngredientCache::new();
10599

106100
impl $zalsa::SalsaStructInDb for $InternedData<'_> {
107101
type MemoIngredientMap = $zalsa::MemoIngredientSingletonIndex;

components/salsa-macro-rules/src/setup_tracked_struct.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,9 @@ macro_rules! setup_tracked_struct {
173173
Self::ingredient_(db.zalsa())
174174
}
175175

176-
// Suppress the lint against `cfg(loom)`.
177-
#[allow(unexpected_cfgs)]
178176
fn ingredient_(zalsa: &$zalsa::Zalsa) -> &$zalsa_struct::IngredientImpl<Self> {
179-
$zalsa::__maybe_lazy_static! {
180-
static CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Configuration>> =
181-
$zalsa::IngredientCache::new();
182-
}
177+
static CACHE: $zalsa::IngredientCache<$zalsa_struct::IngredientImpl<$Configuration>> =
178+
$zalsa::IngredientCache::new();
183179

184180
CACHE.get_or_create(zalsa, || {
185181
zalsa.add_or_lookup_jar_by_type::<$zalsa_struct::JarImpl<$Configuration>>()

justfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
test:
2-
cargo test --workspace --all-features --all-targets --no-fail-fast
2+
cargo test --workspace --all-targets --no-fail-fast
33

44
miri:
5-
cargo +nightly miri test --no-fail-fast --all-features
5+
cargo +nightly miri test --no-fail-fast
66

7-
loom:
8-
RUSTFLAGS="--cfg loom" cargo check --workspace --features loom
7+
shuttle:
8+
cargo test --features shuttle --test parallel
99

1010
all: test miri

src/accumulator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use accumulated::{Accumulated, AnyAccumulated};
1010
use crate::cycle::CycleHeads;
1111
use crate::function::VerifyResult;
1212
use crate::ingredient::{Ingredient, Jar};
13-
use crate::loom::sync::Arc;
1413
use crate::plumbing::{IngredientIndices, ZalsaLocal};
14+
use crate::sync::Arc;
1515
use crate::table::memo::MemoTableTypes;
1616
use crate::zalsa::{IngredientIndex, Zalsa};
1717
use crate::{Database, Id, Revision};

src/accumulator/accumulated_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_hash::FxHashMap;
44

55
use crate::accumulator::accumulated::Accumulated;
66
use crate::accumulator::{Accumulator, AnyAccumulated};
7-
use crate::loom::sync::atomic::{AtomicBool, Ordering};
7+
use crate::sync::atomic::{AtomicBool, Ordering};
88
use crate::IngredientIndex;
99

1010
#[derive(Default)]

src/active_query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::cycle::CycleHeads;
88
use crate::durability::Durability;
99
use crate::hash::FxIndexSet;
1010
use crate::key::DatabaseKeyIndex;
11-
use crate::loom::sync::atomic::AtomicBool;
1211
use crate::runtime::Stamp;
12+
use crate::sync::atomic::AtomicBool;
1313
use crate::tracked_struct::{Disambiguator, DisambiguatorMap, IdentityHash, IdentityMap};
1414
use crate::zalsa_local::{QueryEdge, QueryEdges, QueryOrigin, QueryRevisions};
1515
use crate::{Accumulator, IngredientIndex, Revision};

src/attach.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
use std::cell::Cell;
12
use std::ptr::NonNull;
23

3-
use crate::loom::cell::Cell;
44
use crate::Database;
55

6-
#[cfg(loom)]
7-
crate::loom::thread_local! {
6+
#[cfg(feature = "shuttle")]
7+
crate::sync::thread_local! {
88
/// The thread-local state salsa requires for a given thread
99
static ATTACHED: Attached = Attached::new();
1010
}
1111

12-
// loom's `thread_local` macro does not support const-initialization.
13-
#[cfg(not(loom))]
14-
crate::loom::thread_local! {
12+
// shuttle's `thread_local` macro does not support const-initialization.
13+
#[cfg(not(feature = "shuttle"))]
14+
crate::sync::thread_local! {
1515
/// The thread-local state salsa requires for a given thread
1616
static ATTACHED: Attached = const { Attached::new() }
1717
}
@@ -28,14 +28,6 @@ struct Attached {
2828
}
2929

3030
impl Attached {
31-
#[cfg(loom)]
32-
fn new() -> Self {
33-
Self {
34-
database: Cell::new(None),
35-
}
36-
}
37-
38-
#[cfg(not(loom))]
3931
const fn new() -> Self {
4032
Self {
4133
database: Cell::new(None),
@@ -58,9 +50,7 @@ impl Attached {
5850
Some(current_db) => {
5951
let new_db = NonNull::from(db);
6052
if !std::ptr::addr_eq(current_db.as_ptr(), new_db.as_ptr()) {
61-
panic!(
62-
"Cannot change database mid-query. current: {current_db:?}, new: {new_db:?}",
63-
);
53+
panic!("Cannot change database mid-query. current: {current_db:?}, new: {new_db:?}");
6454
}
6555
Self { state: None }
6656
}

src/cycle.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ use std::panic;
5555
use thin_vec::{thin_vec, ThinVec};
5656

5757
use crate::key::DatabaseKeyIndex;
58+
use crate::sync::OnceLock;
5859

5960
/// The maximum number of times we'll fixpoint-iterate before panicking.
6061
///
@@ -258,13 +259,9 @@ impl From<CycleHead> for CycleHeads {
258259
}
259260
}
260261

261-
#[cfg(not(loom))]
262-
pub(crate) static EMPTY_CYCLE_HEADS: std::sync::LazyLock<CycleHeads> =
263-
std::sync::LazyLock::new(|| CycleHeads(ThinVec::new()));
264-
265-
#[cfg(loom)]
266-
loom::lazy_static! {
267-
pub(crate) static ref EMPTY_CYCLE_HEADS: CycleHeads = CycleHeads(ThinVec::new());
262+
pub(crate) fn empty_cycle_heads() -> &'static CycleHeads {
263+
static EMPTY_CYCLE_HEADS: OnceLock<CycleHeads> = OnceLock::new();
264+
EMPTY_CYCLE_HEADS.get_or_init(|| CycleHeads(ThinVec::new()))
268265
}
269266

270267
#[derive(Debug, PartialEq, Eq)]

src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::key::DatabaseKeyIndex;
2-
use crate::loom::thread::{self, ThreadId};
2+
use crate::sync::thread::{self, ThreadId};
33
use crate::Revision;
44

55
/// The `Event` struct identifies various notable things that can

src/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use crate::function::delete::DeletedEntries;
1010
use crate::function::sync::{ClaimResult, SyncTable};
1111
use crate::ingredient::Ingredient;
1212
use crate::key::DatabaseKeyIndex;
13-
use crate::loom::sync::Arc;
1413
use crate::plumbing::MemoIngredientMap;
1514
use crate::salsa_struct::SalsaStructInDb;
15+
use crate::sync::Arc;
1616
use crate::table::memo::MemoTableTypes;
1717
use crate::table::Table;
1818
use crate::views::DatabaseDownCaster;

src/function/execute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::cycle::{CycleRecoveryStrategy, MAX_ITERATIONS};
22
use crate::function::memo::Memo;
33
use crate::function::{Configuration, IngredientImpl};
4-
use crate::loom::sync::atomic::{AtomicBool, Ordering};
4+
use crate::sync::atomic::{AtomicBool, Ordering};
55
use crate::zalsa::{MemoIngredientIndex, Zalsa, ZalsaDatabase};
66
use crate::zalsa_local::{ActiveQueryGuard, QueryRevisions};
77
use crate::{Event, EventKind, Id, Revision};

src/function/fetch.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::cycle::{CycleHeads, CycleRecoveryStrategy, UnexpectedCycle};
22
use crate::function::memo::Memo;
33
use crate::function::sync::ClaimResult;
44
use crate::function::{Configuration, IngredientImpl, VerifyResult};
5-
use crate::loom::sync::AtomicMut;
65
use crate::zalsa::{MemoIngredientIndex, Zalsa, ZalsaDatabase};
76
use crate::zalsa_local::QueryRevisions;
87
use crate::Id;
@@ -163,7 +162,7 @@ where
163162
let mut revisions = active_query.pop();
164163
revisions.cycle_heads = CycleHeads::initial(database_key_index);
165164
// We need this for `cycle_heads()` to work. We will unset this in the outer `execute()`.
166-
revisions.verified_final.write_mut(false);
165+
*revisions.verified_final.get_mut() = false;
167166
Some(self.insert_memo(
168167
zalsa,
169168
id,

src/function/lru.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::num::NonZeroUsize;
22

33
use crate::hash::FxLinkedHashSet;
4-
use crate::loom::sync::Mutex;
4+
use crate::sync::Mutex;
55
use crate::Id;
66

77
pub(super) struct Lru {

src/function/maybe_changed_after.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use crate::function::memo::Memo;
44
use crate::function::sync::ClaimResult;
55
use crate::function::{Configuration, IngredientImpl};
66
use crate::key::DatabaseKeyIndex;
7-
use crate::loom::sync::atomic::Ordering;
87
use crate::plumbing::ZalsaLocal;
8+
use crate::sync::atomic::Ordering;
99
use crate::zalsa::{MemoIngredientIndex, Zalsa, ZalsaDatabase};
1010
use crate::zalsa_local::{QueryEdge, QueryOrigin};
1111
use crate::{AsDynDatabase as _, Id, Revision};

0 commit comments

Comments
 (0)