Skip to content

Commit

Permalink
Re-enable stacked borrows in CI
Browse files Browse the repository at this point in the history
Also improve performance of some tests in Miri
  • Loading branch information
clubby789 authored and vorner committed Dec 25, 2022
1 parent a41840b commit 4793409
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ jobs:
- name: Run miri
env:
PROPTEST_CASES: "10"
# TODO: Do something with the stacked borrows. Figure out what it means.
MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows"
MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-permissive-provenance"
run: cargo miri test --all-features

thread_sanitizer-MacOS:
Expand Down
13 changes: 10 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ macro_rules! t {
const WRITER_CNT: usize = 2;
const READER_CNT: usize = 3;
#[cfg(miri)]
const ITERATIONS: usize = 10;
const ITERATIONS: usize = 5;
#[cfg(not(miri))]
const ITERATIONS: usize = 100;
const SEQ: usize = 50;
Expand Down Expand Up @@ -1160,6 +1160,9 @@ macro_rules! t {
#[test]
/// Make sure the reference count and compare_and_swap works as expected.
fn cas_ref_cnt() {
#[cfg(miri)]
const ITERATIONS: usize = 10;
#[cfg(not(miri))]
const ITERATIONS: usize = 50;
let shared = ArcSwap::from(Arc::new(0));
for i in 0..ITERATIONS {
Expand All @@ -1173,7 +1176,7 @@ macro_rules! t {
// Fill up the slots sometimes
let fillup = || {
if i % 2 == 0 {
Some((0..50).map(|_| shared.load()).collect::<Vec<_>>())
Some((0..ITERATIONS).map(|_| shared.load()).collect::<Vec<_>>())
} else {
None
}
Expand Down Expand Up @@ -1272,10 +1275,14 @@ mod tests {
/// created, but contain full Arcs.
#[test]
fn lease_overflow() {
#[cfg(miri)]
const GUARD_COUNT: usize = 100;
#[cfg(not(miri))]
const GUARD_COUNT: usize = 1000;
let a = Arc::new(0);
let shared = ArcSwap::from(Arc::clone(&a));
assert_eq!(2, Arc::strong_count(&a));
let mut guards = (0..1000).map(|_| shared.load()).collect::<Vec<_>>();
let mut guards = (0..GUARD_COUNT).map(|_| shared.load()).collect::<Vec<_>>();
let count = Arc::strong_count(&a);
assert!(count > 2);
let guard = shared.load();
Expand Down

0 comments on commit 4793409

Please sign in to comment.