Skip to content

Commit 0414d89

Browse files
authored
Replace loom with shuttle (#876)
* replace loom with shuttle * inline `empty_cycle_heads` * ignore failing shuttle test
1 parent f7b0856 commit 0414d89

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

+529
-607
lines changed

.github/workflows/test.yml

Lines changed: 31 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,39 @@ 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+
- name: Setup Rust toolchain
102+
uses: dtolnay/rust-toolchain@master
103+
id: rust-toolchain
104+
with:
105+
toolchain: stable
106+
- uses: taiki-e/install-action@nextest
107+
- uses: actions/cache@v4
108+
with:
109+
path: |
110+
~/.cargo/bin/
111+
~/.cargo/registry/index/
112+
~/.cargo/registry/cache/
113+
~/.cargo/git/db/
114+
target/
115+
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.toml') }}
116+
restore-keys: |
117+
${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.cachekey }}-
118+
${{ runner.os }}-cargo-
119+
- name: Test with Shuttle
120+
run: cargo nextest run --features shuttle --test parallel
121+
97122
benchmarks:
98123
# https://github.com/CodSpeedHQ/action/issues/126
99124
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.22.0", 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 nextest run --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)]

0 commit comments

Comments
 (0)