From dfe4a7bf38fdd5fce412da27ff504f84b58eca22 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 07:26:58 -0700 Subject: [PATCH 1/2] chore(quest): claim quest/m1/kio-workspace-tests.md Quest-Claim: f0bdc2cd7fa0cc55 From f6efc31e2cc7b97af5c73586b9467ee62d9fa608 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 07:32:34 -0700 Subject: [PATCH 2/2] test(kio): isolate log reclamation tests sharing the epoch collector Co-Authored-By: GPT-6.1 --- quest/m1/README.md | 1 - quest/m1/kio-workspace-tests.md | 28 ---------------------------- rs/kio/src/log.rs | 23 ++++++++++++++++++++--- 3 files changed, 20 insertions(+), 32 deletions(-) delete mode 100644 quest/m1/kio-workspace-tests.md diff --git a/quest/m1/README.md b/quest/m1/README.md index 48bc378104c..8bb74e38b2a 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -173,7 +173,6 @@ removed). - [crates.io trusts the workflow](/quest/m1/crates-trusted-publisher.md) - maintainer action: every published crate gets a trusted publisher for `release-rs.yml` - [Rust releases publish through OIDC](/quest/m1/release-rs-oidc.md) - release-plz publishes with trusted publishing and `CARGO_REGISTRY_TOKEN` is revoked - [moq-clock's tests pass under cargo test](/quest/m1/clock-test-process.md) - `paused_runtimes_own_their_anchors` stops depending on being first in its process -- [kio's log tests pass in a workspace build](/quest/m1/kio-workspace-tests.md) - the eviction tests pass under the workspace's unified features, or eviction is fixed - [The JS stalled-consumer eviction test ages its groups](/quest/m1/js-cache-age-test.md) - the test drives the clock the cache reads, so it can fail - [Main is no slower than release](/quest/m1/release-perf/README.md) - every benchmark where main is slower than release is fixed or accepted with a reason, checked by a final paired run before the cut - [Interop coverage](/quest/m1/interop-coverage/README.md) - the riskiest moq-transport features moq-net exposes get cross-implementation tests over drafts 18 and 22 diff --git a/quest/m1/kio-workspace-tests.md b/quest/m1/kio-workspace-tests.md deleted file mode 100644 index 4bde0073b49..00000000000 --- a/quest/m1/kio-workspace-tests.md +++ /dev/null @@ -1,28 +0,0 @@ -# [S] kio's log tests pass in a workspace build - -## Goal - -kio's log eviction tests, including `eviction_frees_whatever_readers_do`, -pass in `cargo test --workspace` as they do in `cargo test -p kio`. If the -workspace build exposes a real eviction bug, the code is fixed, not the -test. - -## Plan - -Decided 2026-10-29 (maintainer), a follow-up of -[moq-dev/moq#7161](https://github.com/moq-dev/moq/pull/7161), whose agent saw -two kio log tests fail only in a `--workspace` run. - -Checked 2026-10-29: `cargo test -p kio --lib` passes with and without the -`_sim` feature, so the trigger is another dependency feature the workspace -unifies, such as one of `crossbeam-epoch`'s (kio frees evicted segments -through epoch reclamation). The cargo-hakari workspace-hack in -[moq-dev/moq#6985](https://github.com/moq-dev/moq/pull/6985) excludes kio, so -it will not fix this. - -Find the feature that flips the result, then decide whether the test assumed -something the code doesn't promise (such as when a deferred free runs) or -whether eviction is wrong under that feature. Prove the fix by running the -tests under the unified feature set. - -Public API: none. Wire: none. diff --git a/rs/kio/src/log.rs b/rs/kio/src/log.rs index e7abe6684fe..52443a1793d 100644 --- a/rs/kio/src/log.rs +++ b/rs/kio/src/log.rs @@ -564,10 +564,15 @@ impl Read<'_, T> { #[cfg(all(test, not(loom)))] mod test { - use std::sync::Arc as StdArc; + use std::sync::{Arc as StdArc, Mutex}; use super::*; + // Crossbeam shares its collector across logs. Keep unrelated tests from holding + // pins or queuing garbage while another test checks reclamation. Nextest isolates + // tests in processes, but libtest runs them concurrently in one process. + static COLLECTOR: Mutex<()> = Mutex::new(()); + /// The `[start, end)` of each live segment, oldest first. fn layout(writer: &Writer) -> Vec<(u64, u64)> { writer @@ -578,8 +583,7 @@ mod test { .collect() } - /// Run the epoch collector until whatever was retired is freed. Each test runs in its - /// own process, so no other thread holds a pin. + /// Drive reclamation without unrelated pins or garbage, under `COLLECTOR`. fn collect() { for _ in 0..8 { epoch::pin().flush(); @@ -594,6 +598,7 @@ mod test { /// reader that started before any of them existed or one that jumps. #[test] fn reads_every_entry_across_segments() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let mut reader = writer.reader(); assert_eq!(get(&mut reader, 0), Ok(None)); @@ -618,6 +623,7 @@ mod test { /// is allocated. #[test] fn segments_double_up_to_the_largest() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::::new(0); assert_eq!(writer.heap(), Writer::::SHARED); writer.reserve(); @@ -655,6 +661,7 @@ mod test { /// A segment's heap is its allocation's real size. #[test] fn heap_matches_layout() { + let _collector = COLLECTOR.lock().unwrap(); let header = Layout::new::>>(); let slots = Layout::array::>>(4).unwrap(); let layout = header.extend(slots).unwrap().0.pad_to_align(); @@ -664,6 +671,7 @@ mod test { /// A log can start past zero; nothing below its start is readable. #[test] fn starts_past_zero() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(10); let mut reader = writer.reader(); writer.push("a"); @@ -676,6 +684,7 @@ mod test { /// [`Evicted`] rather than a stale entry, even in the segment it last read. #[test] fn eviction_retires_whole_segments() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let mut reader = writer.reader(); for i in 0..10u64 { @@ -705,6 +714,7 @@ mod test { /// and that reader finds them evicted if it does. #[test] fn eviction_frees_whatever_readers_do() { + let _collector = COLLECTOR.lock().unwrap(); let entry = StdArc::new(()); let mut writer = Writer::new(0); let mut reader = writer.reader(); @@ -722,6 +732,7 @@ mod test { /// A read in progress keeps what it can reach until it ends. #[test] fn a_read_outlasts_eviction() { + let _collector = COLLECTOR.lock().unwrap(); let entry = StdArc::new(()); let mut writer = Writer::new(0); let mut reader = writer.reader(); @@ -740,6 +751,7 @@ mod test { /// entry, though the segment it last read was cut off from the new one. #[test] fn a_read_spans_a_full_eviction() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let mut reader = writer.reader(); writer.push(0u64); @@ -756,6 +768,7 @@ mod test { /// misread. #[test] fn evicting_the_tail_starts_a_new_segment() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let mut reader = writer.reader(); for i in 0..2u64 { @@ -783,6 +796,7 @@ mod test { /// Evicting past the end skips those indices: the next entry lands at the new base. #[test] fn evicting_past_the_end_skips() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let mut reader = writer.reader(); writer.reserve(); @@ -801,6 +815,7 @@ mod test { /// A clone reads independently from where the original's segment was. #[test] fn clones_read_independently() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let mut reader = writer.reader(); for i in 0..20u64 { @@ -817,6 +832,7 @@ mod test { /// alive for it. #[test] fn reader_outlives_writer() { + let _collector = COLLECTOR.lock().unwrap(); let entry = StdArc::new(()); let mut writer = Writer::new(0); let mut reader = writer.reader(); @@ -835,6 +851,7 @@ mod test { /// it evicts behind them. #[test] fn concurrent_readers_see_every_entry() { + let _collector = COLLECTOR.lock().unwrap(); let mut writer = Writer::new(0); let readers: Vec<_> = (0..4) .map(|_| {