Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework ci testing #151

Merged
merged 4 commits into from
Aug 7, 2024
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
23 changes: 19 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install cargo tools
uses: taiki-e/install-action@v2
with:
tool: cargo-hack,cargo-minimal-versions
tool: cargo-hack,cargo-minimal-versions${{ matrix.os == 'ubuntu-latest' && ',cargo-fuzz' || '' }}
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default'

- uses: actions/checkout@v4
Expand All @@ -51,7 +51,7 @@ jobs:
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly' && matrix.cargo_features == 'default'

- name: Test
run: cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}"
run: cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}" --all-targets

- name: Minimal versions
# cargo-minimal-versions won't detach the path deps if we're using dev dependencies
Expand All @@ -65,6 +65,21 @@ jobs:
run: cargo update && cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}"
if: matrix.rust == 'stable' && matrix.cargo_features == 'default'

- name: Benchmark
run: cargo +${{ matrix.rust }} bench --no-default-features --features "${{ matrix.cargo_features }}"
- name: Short Fuzz
run: |
cargo +${{ matrix.rust }} install cargo-fuzz --locked
cd fuzz || exit 1
CFLAGS="-fsanitize=address -g -fno-omit-frame-pointer"
targets=( $(cargo metadata --format-version 1 --no-deps | jq -r ".packages[].targets[].name") )
target_triple=$(cargo --version --verbose | grep 'host:' | cut -d ' ' -f 2)
for target in "${targets[@]}"; do
# https://github.com/rust-fuzz/cargo-fuzz/issues/355
cargo +${{ matrix.rust }} fuzz run "$target" --target "${target_triple}" -- -max_total_time=10
done
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default' && matrix.os == 'ubuntu-latest'

- name: Release Test
run: |
cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}" --release --all-targets
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default'

64 changes: 46 additions & 18 deletions croaring/benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,36 @@
group
}};
($new:ident, $inplace:ident, $fast:ident) => {{
let mut group = bench_op!($new, $inplace);
#[cfg(not(feature = "alloc"))]
{
bench_op!($new, $inplace)
}
#[cfg(feature = "alloc")]
{
let mut group = bench_op!($new, $inplace);

group.bench_function("fast", |b| {
b.iter(|| Bitmap::$fast(&[&bitmap1, &bitmap2]));
});
group.bench_function("fast", |b| {
b.iter(|| Bitmap::$fast(&[&bitmap1, &bitmap2]));
});

group
group
}
}};
($new:ident, $inplace:ident, $fast:ident, $fast_heap:ident) => {{
let mut group = bench_op!($new, $inplace, $fast);
#[cfg(not(feature = "alloc"))]
{
bench_op!($new, $inplace, $fast)
}
#[cfg(feature = "alloc")]
{
let mut group = bench_op!($new, $inplace, $fast);

group.bench_function("fast_heap", |b| {
b.iter(|| Bitmap::$fast_heap(&[&bitmap1, &bitmap2]));
});
group.bench_function("fast_heap", |b| {
b.iter(|| Bitmap::$fast_heap(&[&bitmap1, &bitmap2]));
});

group
group
}
}};
}

Expand Down Expand Up @@ -134,6 +148,8 @@
const N: usize = 100_000;
let bitmap: Bitmap = random_iter().take(N).collect();
let mut g = c.benchmark_group("collect");

#[cfg(feature = "alloc")]
g.bench_function("to_vec", |b| {
b.iter(|| bitmap.to_vec());
});
Expand Down Expand Up @@ -178,21 +194,31 @@
}

fn serialize(c: &mut Criterion) {
let mut group = c.benchmark_group("serialize");
for &size in &[100_000, 1_000_000] {
let bitmap: Bitmap = (1..size).collect();
group.throughput(Throughput::Elements(size.into()));
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _| {
b.iter(|| bitmap.serialize::<Portable>());
});
#[cfg(not(feature = "alloc"))]
{
_ = c;
}
#[cfg(feature = "alloc")]
{
let mut group = c.benchmark_group("serialize");
for &size in &[100_000, 1_000_000] {
let bitmap: Bitmap = (1..size).collect();
group.throughput(Throughput::Elements(size.into()));
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _| {
b.iter(|| bitmap.serialize::<Portable>());
});
}
}
}

fn deserialize(c: &mut Criterion) {
let mut group = c.benchmark_group("deserialize");
for &size in &[100_000, 1_000_000] {
let bitmap: Bitmap = (1..size).collect();
let serialized_buffer = bitmap.serialize::<Portable>();
let mut serialized_buffer = vec![0; bitmap.get_serialized_size_in_bytes::<Portable>()];
let serialized_buffer = bitmap
.try_serialize_into::<Portable>(&mut serialized_buffer)
.unwrap();
group.throughput(Throughput::Elements(size.into()));
group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, _| {
b.iter(|| Bitmap::deserialize::<Portable>(&serialized_buffer));
Expand Down Expand Up @@ -252,7 +278,7 @@
fn create_random(c: &mut Criterion) {
const N: u32 = 5_000;
// Clamp values so we get some re-use of containers
const MAX: u32 = 8 * (u16::MAX as u32 + 1);

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest using Rust nightly with features ''

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest using Rust stable with features ''

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on macos-latest using Rust nightly with features ''

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest using Rust stable with features 'alloc'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on macos-latest using Rust stable with features ''

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on macos-latest using Rust stable with features 'alloc'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on macos-latest using Rust nightly with features 'alloc'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest using Rust nightly with features 'alloc'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest using Rust stable with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest using Rust stable with features ''

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on macos-latest using Rust nightly with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on macos-latest using Rust nightly with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest using Rust nightly with features ''

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on macos-latest using Rust stable with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest using Rust stable with features 'alloc'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest using Rust nightly with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest using Rust nightly with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest using Rust stable with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest using Rust nightly with features 'alloc'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest using Rust nightly with features 'default'

constant `MAX` is never used

Check warning on line 281 in croaring/benches/benches.rs

View workflow job for this annotation

GitHub Actions / Test on windows-latest using Rust nightly with features 'default'

constant `MAX` is never used

let mut group = c.benchmark_group("random_iter");
group.throughput(Throughput::Elements(N.into()));
Expand Down Expand Up @@ -285,6 +311,8 @@
let mut group = c.benchmark_group("collect_bitmap64_to_vec");
group.throughput(Throughput::Elements(N.into()));
let bitmap = Bitmap64::from_range(0..N);

#[cfg(feature = "alloc")]
group.bench_function("to_vec", |b| {
b.iter_batched(|| (), |()| bitmap.to_vec(), BatchSize::LargeInput);
});
Expand Down
9 changes: 4 additions & 5 deletions fuzz/Cargo.lock

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

Loading