From 8e760c975c6baebf0d545aaf4dfe0f677886829c Mon Sep 17 00:00:00 2001 From: GZTime Date: Sun, 8 Dec 2024 21:12:27 +0800 Subject: [PATCH 1/5] fix(no_std): use `core::slice` in `bitmap_store.rs` --- roaring/src/bitmap/store/bitmap_store.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roaring/src/bitmap/store/bitmap_store.rs b/roaring/src/bitmap/store/bitmap_store.rs index b4d88b76..cf4649c1 100644 --- a/roaring/src/bitmap/store/bitmap_store.rs +++ b/roaring/src/bitmap/store/bitmap_store.rs @@ -61,7 +61,7 @@ impl BitmapStore { // Safety: It's safe to reinterpret u64s as u8s because u8 has less alignment requirements, // and has no padding/uninitialized data. let dst = unsafe { - std::slice::from_raw_parts_mut(bits.as_mut_ptr().cast::(), BITMAP_BYTES) + core::slice::from_raw_parts_mut(bits.as_mut_ptr().cast::(), BITMAP_BYTES) }; let dst = &mut dst[byte_offset..][..bytes.len()]; dst.copy_from_slice(bytes); From c1f1008b1a6a8789e0d4a80f24a79a772acafcf2 Mon Sep 17 00:00:00 2001 From: GZTime Date: Mon, 9 Dec 2024 22:35:20 +0800 Subject: [PATCH 2/5] wip(ci): do not use `action-rs` [no ci] --- .github/workflows/test.yml | 77 ++++++++++++-------------------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99ed7b3d..e1bb3504 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,88 +34,59 @@ jobs: path: "benchmarks/real-roaring-datasets" - name: Initialize rust toolchain - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master + if: matrix.rust != 'nightly' with: - profile: minimal toolchain: ${{ matrix.rust }} - override: true components: rustfmt, clippy - - name: Install miri + - name: Install nightly toolchain uses: actions-rs/toolchain@v1 if: matrix.rust == 'nightly' with: - profile: minimal - toolchain: nightly - override: true - components: miri + toolchain: ${{ matrix.rust }} + components: rustfmt, clippy, miri - - name: miri setup - uses: actions-rs/cargo@v1 + - name: Setup miri if: matrix.rust == 'nightly' - with: - command: miri - args: setup + run: cargo miri setup - name: Fetch - uses: actions-rs/cargo@v1 - with: - command: fetch + run: cargo fetch - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --all-targets + run: cargo build --all-targets - name: Check - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-targets -- -D warnings + run: cargo clippy --all-targets -- -D warnings - name: Check formatting - uses: actions-rs/cargo@v1 - with: - command: fmt - args: -- --check + run: cargo fmt --all -- --check - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --features serde + working-directory: roaring + run: cargo test --features serde - name: Test bit endian - uses: actions-rs/cargo@v1 if: matrix.rust == 'nightly' - with: - command: miri - args: test --target s390x-unknown-linux-gnu --package roaring --lib -- bitmap::serialization::test::test_from_lsb0_bytes + run: + cargo miri test --target s390x-unknown-linux-gnu --package roaring \ + --lib -- bitmap::serialization::test::test_from_lsb0_bytes - name: Test no default features - uses: actions-rs/cargo@v1 - with: - command: test - args: --no-default-features + working-directory: roaring + run: cargo test --no-default-features - name: Test benchmarks - uses: actions-rs/cargo@v1 - with: - command: bench + working-directory: roaring + run: cargo bench - name: SIMD test if: matrix.rust == 'nightly' - uses: actions-rs/cargo@v1 - with: - toolchain: nightly - command: test - args: --features "simd" + working-directory: roaring + run: cargo +nightly test --features simd - name: SIMD test benchmarks if: matrix.rust == 'nightly' - uses: actions-rs/cargo@v1 - with: - toolchain: nightly - command: bench - args: --features "simd" + working-directory: roaring + run: cargo +nightly bench --features simd From 1a5fb4328350a196d1e0d2bc180615622a93d689 Mon Sep 17 00:00:00 2001 From: GZTime Date: Mon, 9 Dec 2024 23:32:32 +0800 Subject: [PATCH 3/5] chore(fmt): fix rustfmt.toml [no ci] --- rustfmt.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustfmt.toml b/rustfmt.toml index d45dc0e8..2a35f023 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1 @@ -use_small_heuristics = "max" +use_small_heuristics = "Max" From 6acf1585b966dd6e304395befca0bf9a49370a54 Mon Sep 17 00:00:00 2001 From: GZTime Date: Tue, 10 Dec 2024 00:37:10 +0800 Subject: [PATCH 4/5] CI: Make continuous integration more reasonable Co-authored-by: YanWQ-monad --- .github/workflows/test.yml | 144 +++++++++++++----- .../src/bitmap/store/array_store/vector.rs | 4 +- 2 files changed, 104 insertions(+), 44 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1bb3504..e3e60d39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ on: name: Continuous integration jobs: - ci: + build: runs-on: ubuntu-latest strategy: matrix: @@ -21,72 +21,132 @@ jobs: - 1.71.1 env: RUSTFLAGS: "-C target-cpu=native -C opt-level=3" - ROARINGRS_BENCH_OFFLINE: "true" steps: - name: Checkout roaring-rs - uses: actions/checkout@v2 - - - name: Checkout benchmark datasets - uses: actions/checkout@v2 - with: - repository: "RoaringBitmap/real-roaring-datasets" - path: "benchmarks/real-roaring-datasets" + uses: actions/checkout@v4 - name: Initialize rust toolchain uses: dtolnay/rust-toolchain@master - if: matrix.rust != 'nightly' with: toolchain: ${{ matrix.rust }} components: rustfmt, clippy - - name: Install nightly toolchain - uses: actions-rs/toolchain@v1 - if: matrix.rust == 'nightly' - with: - toolchain: ${{ matrix.rust }} - components: rustfmt, clippy, miri - - - name: Setup miri + - name: Check + working-directory: roaring + # clippy will also do a build check + # so we don't need to run `cargo check` or `cargo build` + # use different features to check if everything is fine + # the incremental compilation will make this faster + run: | + cargo clippy --all-targets --no-default-features -- -D warnings + cargo clippy --all-targets --features serde -- -D warnings + + - name: Check SIMD if: matrix.rust == 'nightly' - run: cargo miri setup + working-directory: roaring + run: cargo clippy --all-targets --all-features -- -D warnings - - name: Fetch - run: cargo fetch + - name: Check formatting + run: cargo fmt --all -- --check - - name: Build - run: cargo build --all-targets + test: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + rust: + - stable + - beta + - nightly + - 1.71.1 + features: + - default + - no-std + include: + - rust: nightly + features: simd + env: + RUSTFLAGS: "-C target-cpu=native -C opt-level=3" - - name: Check - run: cargo clippy --all-targets -- -D warnings + steps: + - name: Checkout roaring-rs + uses: actions/checkout@v4 - - name: Check formatting - run: cargo fmt --all -- --check + - name: Initialize rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} - name: Test + if: matrix.features == 'default' working-directory: roaring run: cargo test --features serde - - name: Test bit endian - if: matrix.rust == 'nightly' - run: - cargo miri test --target s390x-unknown-linux-gnu --package roaring \ - --lib -- bitmap::serialization::test::test_from_lsb0_bytes - - name: Test no default features + if: matrix.features == 'no-std' working-directory: roaring run: cargo test --no-default-features - - name: Test benchmarks - working-directory: roaring - run: cargo bench - - name: SIMD test - if: matrix.rust == 'nightly' + if: matrix.rust == 'nightly' && matrix.features == 'simd' working-directory: roaring run: cargo +nightly test --features simd - - name: SIMD test benchmarks - if: matrix.rust == 'nightly' - working-directory: roaring - run: cargo +nightly bench --features simd + miri: + runs-on: ubuntu-latest + needs: build + env: + # warning: Miri does not support optimizations: the opt-level is ignored. + RUSTFLAGS: "-C target-cpu=native" + + steps: + - name: Checkout roaring-rs + uses: actions/checkout@v4 + + - name: Initialize rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly + components: miri + + - name: Setup miri + run: cargo miri setup + + - name: Test bit endian + run: cargo miri test --target s390x-unknown-linux-gnu --package roaring --lib -- bitmap::serialization::test::test_from_lsb0_bytes + + bench: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + rust: + - stable + - nightly + features: + - default + include: + - rust: nightly + features: simd + env: + RUSTFLAGS: "-C target-cpu=native -C opt-level=3" + ROARINGRS_BENCH_OFFLINE: "true" + + steps: + - name: Checkout roaring-rs + uses: actions/checkout@v4 + + - name: Checkout benchmark datasets + uses: actions/checkout@v4 + with: + repository: "RoaringBitmap/real-roaring-datasets" + path: "benchmarks/real-roaring-datasets" + + - name: Initialize rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + + - name: Bench + run: cargo bench --features "${{ matrix.features }}" diff --git a/roaring/src/bitmap/store/array_store/vector.rs b/roaring/src/bitmap/store/array_store/vector.rs index 1a4d69ff..2e33b753 100644 --- a/roaring/src/bitmap/store/array_store/vector.rs +++ b/roaring/src/bitmap/store/array_store/vector.rs @@ -112,7 +112,7 @@ pub fn or(lhs: &[u16], rhs: &[u16], visitor: &mut impl BinaryOperationVisitor) { if rem == 0 { visitor.visit_slice(tail_b) } else { - buffer[..rem as usize].sort_unstable(); + buffer[..rem].sort_unstable(); rem = dedup(&mut buffer[..rem]); scalar::or(&buffer[..rem], tail_b, visitor); } @@ -267,7 +267,7 @@ pub fn xor(lhs: &[u16], rhs: &[u16], visitor: &mut impl BinaryOperationVisitor) if rem == 0 { visitor.visit_slice(tail_b) } else { - buffer[..rem as usize].sort_unstable(); + buffer[..rem].sort_unstable(); rem = xor_slice(&mut buffer[..rem]); scalar::xor(&buffer[..rem], tail_b, visitor); } From c175ea6d1c055c54a8a198622b350e07ea83527c Mon Sep 17 00:00:00 2001 From: GZTime Date: Tue, 10 Dec 2024 09:32:25 +0800 Subject: [PATCH 5/5] wip: use `-p roaring` instaed of working-directory --- .github/workflows/test.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3e60d39..b771dc94 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,19 +33,17 @@ jobs: components: rustfmt, clippy - name: Check - working-directory: roaring # clippy will also do a build check # so we don't need to run `cargo check` or `cargo build` # use different features to check if everything is fine # the incremental compilation will make this faster run: | - cargo clippy --all-targets --no-default-features -- -D warnings - cargo clippy --all-targets --features serde -- -D warnings + cargo clippy -p roaring --all-targets --no-default-features -- -D warnings + cargo clippy -p roaring --all-targets --features serde -- -D warnings - name: Check SIMD if: matrix.rust == 'nightly' - working-directory: roaring - run: cargo clippy --all-targets --all-features -- -D warnings + run: cargo clippy -p roaring --all-targets --all-features -- -D warnings - name: Check formatting run: cargo fmt --all -- --check @@ -80,18 +78,15 @@ jobs: - name: Test if: matrix.features == 'default' - working-directory: roaring - run: cargo test --features serde + run: cargo test -p roaring --features serde - name: Test no default features if: matrix.features == 'no-std' - working-directory: roaring - run: cargo test --no-default-features + run: cargo test -p roaring --no-default-features - name: SIMD test if: matrix.rust == 'nightly' && matrix.features == 'simd' - working-directory: roaring - run: cargo +nightly test --features simd + run: cargo +nightly test -p roaring --features simd miri: runs-on: ubuntu-latest @@ -114,7 +109,7 @@ jobs: run: cargo miri setup - name: Test bit endian - run: cargo miri test --target s390x-unknown-linux-gnu --package roaring --lib -- bitmap::serialization::test::test_from_lsb0_bytes + run: cargo miri test --target s390x-unknown-linux-gnu -p roaring --lib -- bitmap::serialization::test::test_from_lsb0_bytes bench: runs-on: ubuntu-latest