Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ resolver = "2"
# That pin sits above every MSRV here; rust-toolchain.toml says why.
rust-version = "1.91"

[workspace.lints.rust]
# kio and moq-net model-check their primitives under `--cfg loom`.
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)'] }

[workspace.lints.clippy]
# Every suppression says why, so the next lint audit can judge it.
allow_attributes_without_reason = "warn"
Expand Down Expand Up @@ -127,9 +123,6 @@ kio-macros = { version = "0.1.0", path = "rs/kio/macros" }
libc = "0.2"
libloading = "0.9"
linux-raw-sys = { version = "0.12.1", features = ["ioctl"] }
# Permutation testing for the kio primitives (and everything built on them).
# Only compiled under `--cfg loom`; see `just rs loom`.
loom = { version = "0.7.2", features = ["futures"] }
# DNS-SD advertisement and browsing for LAN peer discovery (moq-tokio's `mdns` feature).
# `async` awaits the event channel instead of blocking a thread on it.
mdns-sd = { version = "0.21", features = ["async"] }
Expand Down
11 changes: 6 additions & 5 deletions quest/m2/crossbeam-pin-fence.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Waiting on upstream crossbeam. Once
[crossbeam-rs/crossbeam#1352](https://github.com/crossbeam-rs/crossbeam/issues/1352)
is fixed in a released crossbeam-epoch, the workspace takes that release and
kio's `fence(Release)` in `Read::drop` (`rs/kio/src/log.rs`) is deleted, with
the log eviction loom model still passing on ARM.
kio's log tests still passing on ARM.

Check #1352's state and crossbeam-epoch's latest release. Delete this quest if
upstream declines the fix.
Expand All @@ -25,9 +25,10 @@ Decided 2026-10-28 (maintainer): keep crossbeam-epoch rather than replace it.
refcounted segments and per-read refcounts, it supports loom, and moka pulls
it into moq-relay anyway.

Verify on ARM: run `just rs loom` on an ARM host; Nightly no longer runs it
(decided 2026-10-31, see the [CI epic](/quest/m0/ci/README.md)). Without an
ARM host, force crossbeam's non-x86 branch in a scratch copy, as #7134 did,
and confirm the model passes without the fence.
Verify on ARM: Nightly's `gate` job runs kio's log tests on
`ubuntu-24.04-arm`. The loom model that checked this ordering is gone (decided
2026-10-31, maintainer: "Remove loom entirely"), so also confirm from the
released `Local::pin` that it orders the epoch store before the reads it
guards, which is what the fence restores.

Public API: none. Wire: none.
2 changes: 1 addition & 1 deletion quest/m2/miri-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The hand-written unsafe in `kio` and `moq-net` that touches only memory (no
sockets, GPU, or FFI) runs under Miri nightly, so a use-after-free, data race,
or aliasing violation fails a test instead of waiting for Loom or production.
or aliasing violation fails a test instead of waiting for production.

## Plan

Expand Down
1 change: 0 additions & 1 deletion quest/m2/perf/kio-channel-contention/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ longer contends with readers of the value. Lands with the contended bench (`rs/k
`Consumer`, the `Waiter`, or a caller-held cursor). The `Consumer` is shared
by `&self` across waiters, which argues for a caller-held cursor. Settle it
first, with options and a recommendation.
- Every new atomic protocol gets a loom model in `rs/kio/src/loom.rs`.
- Generic across every `T`, with no moq-net restructure.

2 changes: 1 addition & 1 deletion quest/m2/perf/single-delivery-write.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Decided 2026-10-28 (maintainer): accept the residual in #7141 and explore a
lock-free path here, in m2.

- The risk is a second copy attaching to a frame while it is still being
written. Model that race in loom before relying on it.
written. Rule that race out before relying on it.
- Keep the shared reservation and canonical-content rules #6922 added.
- A measured no-win abandons the quest.

Expand Down
22 changes: 0 additions & 22 deletions rs/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -292,28 +292,6 @@ play *args:
doctest *args:
bash sh/local.sh cargo test --locked --doc "$@"

# `--cfg loom` swaps kio's primitives for loom's, so it rebuilds the world and
# runs only on demand.
# `--release` because a model check runs the body once
# per interleaving (411s -> 51s); the assertions are plain `assert!`. kio's
# models search every interleaving; moq-net's cap preemptions (see
# `tests/loom.rs`, `LOOM_MAX_PREEMPTIONS`). kio's own unit tests are
# `cfg(not(loom))`.

# Permutation-test the concurrent handoffs with loom. `crossbeam_loom` puts the
# epoch collector that frees `kio::log` segments under loom too.
[positional-arguments]
loom *args:
RUSTFLAGS="--cfg loom --cfg crossbeam_loom" cargo test --locked --release -p kio --lib loom:: "$@"
RUSTFLAGS="--cfg loom --cfg crossbeam_loom" cargo test --locked --release -p moq-net --test loom "$@"
RUSTFLAGS="--cfg loom --cfg crossbeam_loom" cargo test --locked --release -p moq-net --test expiry-loom "$@"

# Compile the loom models without running them. The dev profile type-checks
# the same code: after a moq-net edit it took 46s against release's 146s.
loom-check:
RUSTFLAGS="--cfg loom --cfg crossbeam_loom" cargo test --locked --no-run -p kio --lib
RUSTFLAGS="--cfg loom --cfg crossbeam_loom" cargo test --locked --no-run -p moq-net --test loom --test expiry-loom

# Run the moq-quic simulation's random workloads from a fresh seed, printing the settings that replay it, then the bandwidth probe's acceptance suite.
quic-sim:
#!/usr/bin/env bash
Expand Down
8 changes: 0 additions & 8 deletions rs/kio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ crossbeam-epoch = "0.9.21"
kio-macros = { workspace = true, optional = true }
smallvec = { version = "1.15", features = ["union"] }

# Loom swaps in its own Arc/Mutex/atomics so it can permute every interleaving.
# It's a normal (not dev) dependency because `sync.rs` re-exports it from the
# library itself, but `cfg(loom)` is never set outside `just rs loom`.
[target.'cfg(loom)'.dependencies]
# Under `--cfg crossbeam_loom` too, so loom permutes the collector's own atomics.
crossbeam-epoch = { version = "0.9.21", features = ["loom"] }
loom = { workspace = true }

[dev-dependencies]
# Bench-only: the FuturesUnordered comparison in benches/tasks.rs.
criterion = { package = "bench-harness", path = "../bench-harness" }
Expand Down
10 changes: 3 additions & 7 deletions rs/kio/src/bridge.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use std::{
fmt,
ops::{Deref, DerefMut},
// std, not `crate::sync`: `Wake` takes std's Arc.
sync::{Arc, PoisonError},
sync::{Arc, Mutex, MutexGuard, PoisonError},
task::{Context, Wake, Waker},
};

use crate::{
Waiter, WaiterList,
sync::{Mutex, MutexGuard},
};
use crate::{Waiter, WaiterList};

/// A [`Context`]-based handle that any number of waiters poll at once.
///
Expand Down Expand Up @@ -168,7 +164,7 @@ impl<T> fmt::Debug for Bridge<T> {
}
}

#[cfg(all(test, not(loom)))]
#[cfg(test)]
mod tests {
use std::{
sync::atomic::{AtomicUsize, Ordering},
Expand Down
9 changes: 6 additions & 3 deletions rs/kio/src/consumer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::{sync::atomic::Ordering, task::Poll};
use std::{
sync::{Arc, atomic::Ordering},
task::Poll,
};

use crate::{Closed, Counts, State, lock::*, producer::Ref, sync::Arc, waiter::*, weak::ConsumerWeak};
use crate::{Closed, Counts, State, lock::*, producer::Ref, waiter::*, weak::ConsumerWeak};

/// The consuming side of a shared state channel.
///
Expand Down Expand Up @@ -191,7 +194,7 @@ impl<T> Clone for Consumer<T> {
}
}

#[cfg(all(test, not(loom)))]
#[cfg(test)]
mod test {
use crate::{Closed, Producer};
use std::task::Poll;
Expand Down
2 changes: 1 addition & 1 deletion rs/kio/src/coop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Budget {
}
}

#[cfg(all(test, not(loom)))]
#[cfg(test)]
mod tests {
use std::{
sync::{
Expand Down
13 changes: 6 additions & 7 deletions rs/kio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
use std::{
fmt,
ops::{Deref, DerefMut},
sync::atomic::AtomicUsize,
};

use crate::sync::AtomicUsize;

mod lock;
mod sync;
mod waiter;

pub mod coop;
Expand All @@ -49,9 +47,7 @@ mod shared;
mod task;
mod weak;

#[cfg(all(test, loom))]
mod loom;
#[cfg(all(test, not(loom)))]
#[cfg(test)]
mod tests;

#[cfg(feature = "macros")]
Expand Down Expand Up @@ -108,7 +104,10 @@ mod heap {

assert_eq!(arc_heap::<u8>(), layout::<u8>());
assert_eq!(arc_heap::<Overaligned>(), layout::<Overaligned>());
assert_eq!(arc_heap::<sync::Mutex<State<()>>>(), layout::<sync::Mutex<State<()>>>());
assert_eq!(
arc_heap::<std::sync::Mutex<State<()>>>(),
layout::<std::sync::Mutex<State<()>>>()
);
}
}

Expand Down
13 changes: 4 additions & 9 deletions rs/kio/src/lock.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
use std::{
fmt,
ops::{Deref, DerefMut},
// std, not `crate::sync`: [`WeakLock`] needs `Arc::downgrade`, which loom's Arc
// doesn't have. Loom still models the `Mutex` inside, which is the part that
// orders every handle against every other.
sync::{Arc, PoisonError, Weak},
sync::{Arc, Mutex, MutexGuard, PoisonError, Weak},
};

use crate::sync::{Mutex, MutexGuard};

/// A cloneable mutex wrapper backed by `Arc<Mutex<T>>`.
///
/// Every kio channel keeps its state in one of these, with its [`WaiterList`]s inside,
Expand All @@ -34,12 +29,12 @@ pub struct Lock<T> {
inner: Arc<Mutex<T>>,
}

// SAFETY: std and loom's Mutex<T> are Send + Sync when T: Send, so this is
// SAFETY: Mutex<T> is Send + Sync when T: Send, so this is
// exactly Arc<Mutex<T>>'s derived bound. Stopping here keeps recursive channel
// graphs from expanding the same Arc/Mutex proof at every level.
unsafe impl<T: Send> Send for Lock<T> {}

// SAFETY: Arc<Mutex<T>> has the same T: Send bound for Sync, with either mutex.
// SAFETY: Arc<Mutex<T>> has the same T: Send bound for Sync.
unsafe impl<T: Send> Sync for Lock<T> {}

impl<T> Lock<T> {
Expand Down Expand Up @@ -158,7 +153,7 @@ impl<T> Default for WeakLock<T> {
}
}

#[cfg(all(test, not(loom)))]
#[cfg(test)]
mod tests {
use super::*;

Expand Down
Loading