Skip to content

Commit 29de7cb

Browse files
author
Mark Hildebrand
committed
Merge remote-tracking branch 'origin/main' into mhildebr/byo-type-erasure
2 parents dd99cba + ccf8d4c commit 29de7cb

298 files changed

Lines changed: 25289 additions & 14369 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/setup-disk-benchmark/action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ runs:
2323
steps:
2424
- name: Install Rust
2525
shell: bash
26-
run: rustup show
26+
run: |
27+
if ! command -v rustup &>/dev/null; then
28+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
29+
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
30+
fi
2731
32+
- name: Show Rust toolchain
33+
shell: bash
34+
run: rustup show
35+
2836
- name: Install system dependencies
2937
shell: bash
3038
run: |
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT license.
4+
#
5+
# Compare two cargo-llvm-lines output files and produce a markdown regression report.
6+
#
7+
# Usage:
8+
# ./compare-llvm-lines.sh <baseline.txt> <current.txt>
9+
10+
set -euo pipefail
11+
12+
if [ $# -lt 2 ]; then
13+
echo "Usage: $0 <baseline.txt> <current.txt>" >&2
14+
exit 1
15+
fi
16+
17+
baseline_file="$1"
18+
current_file="$2"
19+
20+
baseline_total=$(awk '/\(TOTAL\)/{print $1}' "$baseline_file")
21+
current_total=$(awk '/\(TOTAL\)/{print $1}' "$current_file")
22+
23+
if [ "$baseline_total" -eq 0 ]; then
24+
echo "Error: baseline total is 0, cannot compute growth." >&2
25+
exit 1
26+
fi
27+
28+
delta_total=$(( current_total - baseline_total ))
29+
30+
# Parse llvm-lines output into "lines\tfunction_name" format.
31+
# Skip header (3 lines) and TOTAL row. Extract the first number (lines count)
32+
# and the function name (everything after the second parenthesized group).
33+
parse() {
34+
awk 'NR>3 && !/TOTAL/{
35+
lines = $1
36+
sub(/^[^)]*\)[^)]*\) */, "")
37+
print lines "\t" $0
38+
}' "$1" | sort -t$'\t' -k2
39+
}
40+
41+
tmpdir=$(mktemp -d)
42+
trap 'rm -rf "$tmpdir"' EXIT
43+
baseline_parsed_file="$tmpdir/llvm_baseline_parsed.txt"
44+
current_parsed_file="$tmpdir/llvm_current_parsed.txt"
45+
46+
parse "$baseline_file" > "$baseline_parsed_file"
47+
parse "$current_file" > "$current_parsed_file"
48+
49+
echo "| Delta | Current | Baseline | Function |"
50+
echo "|-------|---------|----------|----------|"
51+
printf "| %+d | %s | %s | (TOTAL) |\n" "$delta_total" "$current_total" "$baseline_total"
52+
join -t$'\t' -j 2 -a1 -a2 -e 0 -o 0,1.1,2.1 \
53+
"$current_parsed_file" "$baseline_parsed_file" | \
54+
awk -F'\t' '{delta=$2-$3; printf "%d\t%s\t%s\t%s\n", delta, $2, $3, $1}' | \
55+
sort -t$'\t' -k1,1rn -k2,2rn | \
56+
awk -F'\t' '{printf "| %+d | %s | %s | %s |\n", $1, $2, $3, $4}'
57+
echo ""

.github/workflows/ci.yml

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222
CARGO_TERM_COLOR: always
2323
# The features we want to explicitly test. For example, the `flatbuffers-build` feature
2424
# of `diskann-quantization` requires additional setup and so must not be included by default.
25-
DISKANN_FEATURES: "virtual_storage,bf_tree,spherical-quantization,product-quantization,tracing,experimental_diversity_search,disk-index,flatbuffers,linalg,codegen"
25+
DISKANN_FEATURES: "virtual_storage,spherical-quantization,product-quantization,tracing,experimental_diversity_search,disk-index,flatbuffers,linalg,codegen"
2626

2727
# Intel SDE version used for baseline and AVX-512 emulation jobs.
2828
SDE_VERSION: "sde-external-10.7.0-2026-02-18-lin"
@@ -257,6 +257,8 @@ jobs:
257257
needs: basics
258258
name: sde-baseline-tests
259259
runs-on: ubuntu-latest
260+
if:
261+
false # Disabled until we can resolve SDE binary downloads.
260262
env:
261263
# Compile for the x86-64 baseline — no AVX, no AVX2.
262264
RUSTFLAGS: "-Dwarnings -Ctarget-cpu=x86-64"
@@ -318,6 +320,8 @@ jobs:
318320
needs: basics
319321
name: sde-avx512-tests
320322
runs-on: ubuntu-latest
323+
if:
324+
false # Disabled until we can resolve SDE binary downloads.
321325
env:
322326
# Use SDE as the test runner so cargo test automatically runs binaries under emulation.
323327
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: "${{ github.workspace }}/intel-sde/sde64 -spr --"
@@ -487,29 +491,59 @@ jobs:
487491
env:
488492
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
489493

490-
miri:
494+
# LLVM IR bloat check: compare monomorphization cost against baseline.
495+
# This job is not part of the required CI gate, so it won't block PR merges.
496+
llvm-lines:
497+
if: github.event_name == 'pull_request'
491498
needs: basics
492-
name: miri-test
493-
# This step is slow, so it only runs after a PR merge to avoid slowing down pre-merge checks.
494-
if: ${{ github.event_name == 'push' }}
499+
name: LLVM Lines Regression Check
495500
runs-on: ubuntu-latest
496-
continue-on-error: true
501+
env:
502+
LLVM_LINES_GROWTH_THRESHOLD: 5
497503
steps:
498-
- uses: actions/checkout@v4
504+
- name: Checkout current branch
505+
uses: actions/checkout@v4
499506
with:
500-
lfs: true
501-
502-
- name: Install Rust nightly with miri
503-
run: rustup toolchain install nightly --component miri
507+
path: pr
504508

505-
- name: Install cargo-nextest
506-
uses: taiki-e/install-action@v2
509+
- name: Checkout base ref
510+
uses: actions/checkout@v4
507511
with:
508-
tool: cargo-nextest
512+
ref: ${{ github.event.pull_request.base.sha }}
513+
path: baseline
514+
515+
- name: Install Rust
516+
shell: bash
517+
run: rustup show
518+
working-directory: pr
519+
520+
- name: Install cargo-llvm-lines
521+
run: cargo install cargo-llvm-lines --locked
509522

510523
- uses: Swatinem/rust-cache@v2
524+
with:
525+
workspaces: |
526+
pr -> target
527+
baseline -> target
511528
512-
- name: miri
513-
run: cargo +nightly miri nextest run --locked --package diskann-quantization
514-
env:
515-
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
529+
- name: Generate baseline LLVM lines
530+
working-directory: baseline
531+
run: cargo llvm-lines --package diskann-benchmark --all-features --release | head -100 | tee ../baseline-llvm-lines.txt
532+
533+
- name: Generate current LLVM lines
534+
working-directory: pr
535+
run: cargo llvm-lines --package diskann-benchmark --all-features --release | head -100 | tee ../current-llvm-lines.txt
536+
537+
- name: Compare LLVM lines
538+
run: bash pr/.github/scripts/compare-llvm-lines.sh baseline-llvm-lines.txt current-llvm-lines.txt
539+
540+
- name: Check LLVM lines growth threshold
541+
run: |
542+
baseline_total=$(awk '/\(TOTAL\)/{print $1}' baseline-llvm-lines.txt)
543+
current_total=$(awk '/\(TOTAL\)/{print $1}' current-llvm-lines.txt)
544+
growth=$(( (current_total - baseline_total) * 100 / baseline_total ))
545+
546+
if [ "$growth" -gt "$LLVM_LINES_GROWTH_THRESHOLD" ]; then
547+
echo "::error::LLVM IR grew ${growth}% ($baseline_total → $current_total lines), threshold is ${LLVM_LINES_GROWTH_THRESHOLD}%"
548+
exit 1
549+
fi

.github/workflows/disk-benchmarks-aa.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
# A/A benchmark: run main vs main to detect environment noise.
3838
aa-benchmark:
3939
name: A/A - ${{ matrix.dataset }}
40-
runs-on: ubuntu-latest
40+
runs-on: [ self-hosted, 1ES.Pool=diskann-github, ubuntu-latest, "JobId=aa-benchmark-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ strategy.job-index }}" ]
4141
timeout-minutes: 120
4242
strategy:
4343
fail-fast: false
@@ -51,6 +51,20 @@ jobs:
5151
archive: openai-100K.tar.gz
5252

5353
steps:
54+
# Kept inline because this must run before checkout, but local action.yml
55+
# files are only available after checkout.
56+
- name: Mount high-speed NVMe SSD
57+
shell: bash
58+
run: |
59+
sudo mkdir -p /mnt/nvme
60+
sudo lsblk
61+
sudo mkfs.ext4 /dev/nvme0n1
62+
sudo mount /dev/nvme0n1 /mnt/nvme
63+
sudo chmod 777 /mnt/nvme
64+
mkdir -p /mnt/nvme/diskann_rust /mnt/nvme/baseline
65+
ln -s /mnt/nvme/diskann_rust diskann_rust
66+
ln -s /mnt/nvme/baseline baseline
67+
5468
- name: Checkout main
5569
uses: actions/checkout@v4
5670
with:

.github/workflows/disk-benchmarks.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
# Macro benchmark: compare current branch against baseline
5555
macro-benchmark:
5656
name: Macro Benchmark - ${{ matrix.dataset }}
57-
runs-on: ubuntu-latest
57+
runs-on: [ self-hosted, 1ES.Pool=diskann-github, ubuntu-latest, "JobId=macro-benchmark-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ strategy.job-index }}" ]
5858
# TODO: For production benchmarks, consider using a self-hosted runner with:
5959
# - NVMe storage for consistent I/O performance
6060
# - CPU pinning (taskset) for reduced variance
@@ -74,6 +74,20 @@ jobs:
7474
data_dir: OpenAIArXiv
7575

7676
steps:
77+
# Kept inline because this must run before checkout, but local action.yml
78+
# files are only available after checkout.
79+
- name: Mount high-speed NVMe SSD
80+
shell: bash
81+
run: |
82+
sudo mkdir -p /mnt/nvme
83+
sudo lsblk
84+
sudo mkfs.ext4 /dev/nvme0n1
85+
sudo mount /dev/nvme0n1 /mnt/nvme
86+
sudo chmod 777 /mnt/nvme
87+
mkdir -p /mnt/nvme/diskann_rust /mnt/nvme/baseline
88+
ln -s /mnt/nvme/diskann_rust diskann_rust
89+
ln -s /mnt/nvme/baseline baseline
90+
7791
- name: Checkout current branch
7892
uses: actions/checkout@v4
7993
with:

.github/workflows/nightly.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT license.
3+
4+
on:
5+
schedule:
6+
# Run nightly at 2 AM UTC.
7+
- cron: "0 2 * * *"
8+
workflow_dispatch:
9+
10+
name: Nightly
11+
12+
concurrency:
13+
group: ${{ github.workflow }}
14+
cancel-in-progress: true
15+
16+
env:
17+
RUST_CONFIG: 'build.rustflags=["-Dwarnings"]'
18+
RUST_BACKTRACE: 1
19+
CARGO_TERM_COLOR: always
20+
DISKANN_FEATURES: "virtual_storage,spherical-quantization,product-quantization,tracing,experimental_diversity_search,disk-index,flatbuffers,linalg,codegen"
21+
22+
defaults:
23+
run:
24+
shell: bash
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
clippy-default-features:
31+
name: clippy-default-features (macos)
32+
runs-on: macos-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Install Rust
36+
run: rustup show && rustup component add clippy
37+
- uses: Swatinem/rust-cache@v2
38+
- name: "clippy --workspace --all-targets"
39+
run: cargo clippy --locked --workspace --all-targets --no-deps --config "$RUST_CONFIG" -- -Dwarnings
40+
41+
clippy-features:
42+
name: clippy-features (macos)
43+
runs-on: macos-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Install Rust
47+
run: rustup show && rustup component add clippy
48+
- uses: Swatinem/rust-cache@v2
49+
- name: "clippy --workspace --all-targets --features"
50+
run: |
51+
set -euxo pipefail
52+
cargo clippy --locked --workspace \
53+
--all-targets \
54+
--no-deps \
55+
--features ${{ env.DISKANN_FEATURES }} \
56+
--config "$RUST_CONFIG" \
57+
-- -Dwarnings
58+
59+
test-workspace:
60+
needs:
61+
- clippy-default-features
62+
- clippy-features
63+
name: test workspace (macos)
64+
runs-on: macos-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
with:
68+
lfs: true
69+
70+
- name: Install Rust
71+
run: rustup show
72+
73+
- name: Install cargo-nextest
74+
uses: taiki-e/install-action@v2
75+
with:
76+
tool: cargo-nextest
77+
78+
- uses: Swatinem/rust-cache@v2
79+
80+
- name: test workspace with nextest
81+
run: |
82+
set -euxo pipefail
83+
cargo nextest run --locked --workspace --cargo-profile ci --config "$RUST_CONFIG"
84+
cargo test --locked --doc --workspace --profile ci --config "$RUST_CONFIG"
85+
86+
test-workspace-features:
87+
needs:
88+
- clippy-default-features
89+
- clippy-features
90+
name: test workspace (macos, all features)
91+
runs-on: macos-latest
92+
steps:
93+
- uses: actions/checkout@v4
94+
with:
95+
lfs: true
96+
97+
- name: Install Rust
98+
run: rustup show
99+
100+
- name: Install cargo-nextest
101+
uses: taiki-e/install-action@v2
102+
with:
103+
tool: cargo-nextest
104+
105+
- uses: Swatinem/rust-cache@v2
106+
107+
- name: test workspace with nextest
108+
run: |
109+
set -euxo pipefail
110+
cargo nextest run --locked --workspace \
111+
--cargo-profile ci \
112+
--config "$RUST_CONFIG" \
113+
--features ${{ env.DISKANN_FEATURES }}
114+
115+
cargo test --locked --doc --workspace --profile ci --config "$RUST_CONFIG"
116+
117+
miri:
118+
name: miri-test
119+
runs-on: ubuntu-latest
120+
continue-on-error: true
121+
steps:
122+
- uses: actions/checkout@v4
123+
with:
124+
lfs: true
125+
126+
- name: Install Rust nightly with miri
127+
run: rustup toolchain install nightly --component miri
128+
129+
- name: Install cargo-nextest
130+
uses: taiki-e/install-action@v2
131+
with:
132+
tool: cargo-nextest
133+
134+
- uses: Swatinem/rust-cache@v2
135+
136+
- name: miri
137+
run: cargo +nightly miri nextest run --locked --package diskann-quantization
138+
env:
139+
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance

.github/workflows/publish-diskann-garnet-nuget.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
artifact-name: linux
2727
lib-path: target/release/libdiskann_garnet.so
2828
- os: windows-latest
29+
env:
30+
EXTRA_RUSTFLAGS: -C control-flow-guard
2931
artifact-name: windows
3032
lib-path: target/release/diskann_garnet.dll
3133
pdb-path: target/release/diskann_garnet.pdb
@@ -35,6 +37,10 @@ jobs:
3537
- uses: Swatinem/rust-cache@v2
3638

3739
- name: Build diskann-garnet (release)
40+
env:
41+
RUSTC_BOOTSTRAP: 1
42+
# NOTE: this overrides flags in /.cargo/config.toml so those must be manually merged in here.
43+
RUSTFLAGS: -Z stack-protector=all -C target-cpu=x86-64-v3 ${{ env.EXTRA_RUSTFLAGS }}
3844
run: cargo build --locked --release --package diskann-garnet
3945

4046
- name: Stage native library

0 commit comments

Comments
 (0)