diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3e5bafb4..061276dd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -234,6 +234,7 @@ jobs: os: - windows-latest - ubuntu-latest + - macos-latest steps: - uses: actions/checkout@v4 @@ -267,6 +268,7 @@ jobs: os: - windows-latest - ubuntu-latest + - macos-latest steps: - uses: actions/checkout@v4 @@ -296,6 +298,43 @@ jobs: cargo test --locked --doc --workspace --profile ci --config "$RUST_CONFIG" + # Test that diskann-benchmark compiles and runs on macOS + # This specifically verifies the io_uring macOS compatibility fix + test-benchmark-macos: + needs: basics + name: test benchmark on macOS + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + lfs: true + + - name: Install Rust ${{ env.rust_stable }} + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.rust_stable }} + + - uses: Swatinem/rust-cache@v2 + + - name: Build diskann-benchmark + run: | + set -euxo pipefail + cargo build --locked --package diskann-benchmark --release --config "$RUST_CONFIG" + + - name: Test benchmark help command + run: | + set -euxo pipefail + cargo run --locked --package diskann-benchmark --release -- --help + + - name: Test benchmark dry-run with example config + run: | + set -euxo pipefail + # Verify it can load the config file and validate it without running + cargo run --locked --package diskann-benchmark --release -- run \ + --input-file ./diskann-benchmark/example/async.json \ + --output-file /tmp/output.json \ + --dry-run + coverage: needs: basics name: code coverage diff --git a/diskann-disk/src/utils/aligned_file_reader/aligned_file_reader_factory.rs b/diskann-disk/src/utils/aligned_file_reader/aligned_file_reader_factory.rs index ef1049003..2fd5f272d 100644 --- a/diskann-disk/src/utils/aligned_file_reader/aligned_file_reader_factory.rs +++ b/diskann-disk/src/utils/aligned_file_reader/aligned_file_reader_factory.rs @@ -7,7 +7,7 @@ use diskann::ANNResult; #[cfg(all(not(miri), target_os = "linux"))] use super::LinuxAlignedFileReader; -#[cfg(miri)] +#[cfg(any(miri, all(not(target_os = "linux"), not(target_os = "windows"))))] use super::StorageProviderAlignedFileReader; #[cfg(all(not(miri), target_os = "windows"))] use super::WindowsAlignedFileReader; @@ -45,6 +45,10 @@ impl AlignedReaderFactory for AlignedFileReaderFactory { #[cfg(all(not(miri), target_os = "windows"))] type AlignedReaderType = WindowsAlignedFileReader; + // Use StorageProviderAlignedFileReader for macOS and other Unix-like systems + #[cfg(all(not(miri), not(target_os = "linux"), not(target_os = "windows")))] + type AlignedReaderType = StorageProviderAlignedFileReader; + fn build(&self) -> ANNResult { #[cfg(miri)] return StorageProviderAlignedFileReader::new( @@ -57,6 +61,12 @@ impl AlignedReaderFactory for AlignedFileReaderFactory { #[cfg(all(not(miri), target_os = "linux"))] return LinuxAlignedFileReader::new(self.file_path.as_str()); + + #[cfg(all(not(miri), not(target_os = "linux"), not(target_os = "windows")))] + return StorageProviderAlignedFileReader::new( + &crate::storage::FileStorageProvider, + self.file_path.as_str(), + ); } } diff --git a/diskann-platform/src/lib.rs b/diskann-platform/src/lib.rs index ab05672a7..57c2e7927 100644 --- a/diskann-platform/src/lib.rs +++ b/diskann-platform/src/lib.rs @@ -9,8 +9,8 @@ pub mod win; #[cfg(windows)] pub use win::*; -#[cfg(not(windows))] +#[cfg(target_os = "linux")] pub mod linux; -#[cfg(not(windows))] +#[cfg(target_os = "linux")] pub use linux::*; diff --git a/diskann-platform/src/linux/ssd_io_context.rs b/diskann-platform/src/linux/ssd_io_context.rs index 2ef6b52b6..3e1a91dbf 100644 --- a/diskann-platform/src/linux/ssd_io_context.rs +++ b/diskann-platform/src/linux/ssd_io_context.rs @@ -3,16 +3,20 @@ * Licensed under the MIT license. */ +#[cfg(target_os = "linux")] use std::fs::File; +#[cfg(target_os = "linux")] use io_uring::IoUring; // The IOContext struct for disk I/O. One for each thread. +#[cfg(target_os = "linux")] pub struct IOContext { pub file_handle: File, pub ring: IoUring, } +#[cfg(target_os = "linux")] impl IOContext { pub fn new(file_handle: File, ring: IoUring) -> Self { IOContext { file_handle, ring }