Skip to content

Commit 6526d6c

Browse files
authored
ci(rust): caching improvements (up to 2.8x faster builds) (lancedb#2075)
Some Rust jobs (such as [Rust/linux](https://github.com/lancedb/lancedb/actions/runs/13019232960/job/36315830779)) take almost minutes. This can be a bit of a bottleneck. * Two fixes to make caches more effective * Check in `Cargo.lock` so that dependencies don't change much between runs * Added a new CI job to validate we can build without a lockfile * Altered build commands so they don't have contradictory features and therefore don't trigger multiple builds Sadly, I don't think there's much to be done for windows-arm64, as much of the compile time is because the base image is so bare we need to install the build tools ourselves.
1 parent da4d7e3 commit 6526d6c

File tree

3 files changed

+8615
-15
lines changed

3 files changed

+8615
-15
lines changed

.github/workflows/rust.yml

+39-12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ env:
2222
# "1" means line tables only, which is useful for panic tracebacks.
2323
RUSTFLAGS: "-C debuginfo=1"
2424
RUST_BACKTRACE: "1"
25+
CARGO_INCREMENTAL: 0
2526

2627
jobs:
2728
lint:
@@ -51,6 +52,28 @@ jobs:
5152
- name: Run clippy
5253
run: cargo clippy --workspace --tests --all-features -- -D warnings
5354

55+
build-no-lock:
56+
runs-on: ubuntu-24.04
57+
timeout-minutes: 30
58+
env:
59+
# Need up-to-date compilers for kernels
60+
CC: clang
61+
CXX: clang++
62+
steps:
63+
- uses: actions/checkout@v4
64+
# Remote cargo.lock to force a fresh build
65+
- name: Remove Cargo.lock
66+
run: rm -f Cargo.lock
67+
- uses: rui314/setup-mold@v1
68+
- uses: Swatinem/rust-cache@v2
69+
- name: Install dependencies
70+
run: |
71+
sudo apt update
72+
sudo apt install -y protobuf-compiler libssl-dev
73+
- name: Build all
74+
run: |
75+
cargo build --benches --all-features --tests
76+
5477
linux:
5578
timeout-minutes: 30
5679
# To build all features, we need more disk space than is available
@@ -75,8 +98,11 @@ jobs:
7598
workspaces: rust
7699
- name: Install dependencies
77100
run: |
78-
sudo apt update
101+
# This shaves 2 minutes off this step in CI. This doesn't seem to be
102+
# necessary in standard runners, but it is in the 4x runners.
103+
sudo rm /var/lib/man-db/auto-update
79104
sudo apt install -y protobuf-compiler libssl-dev
105+
- uses: rui314/setup-mold@v1
80106
- name: Make Swap
81107
run: |
82108
sudo fallocate -l 16G /swapfile
@@ -87,11 +113,11 @@ jobs:
87113
working-directory: .
88114
run: docker compose up --detach --wait
89115
- name: Build
90-
run: cargo build --all-features
116+
run: cargo build --all-features --tests --locked --examples
91117
- name: Run tests
92-
run: cargo test --all-features
118+
run: cargo test --all-features --locked
93119
- name: Run examples
94-
run: cargo run --example simple
120+
run: cargo run --example simple --locked
95121

96122
macos:
97123
timeout-minutes: 30
@@ -115,11 +141,14 @@ jobs:
115141
workspaces: rust
116142
- name: Install dependencies
117143
run: brew install protobuf
118-
- name: Build
119-
run: cargo build --all-features
120144
- name: Run tests
121-
# Run with everything except the integration tests.
122-
run: cargo test --features remote,fp16kernels
145+
run: |
146+
# Don't run the s3 integration tests since docker isn't available
147+
# on this image.
148+
ALL_FEATURES=`cargo metadata --format-version=1 --no-deps \
149+
| jq -r '.packages[] | .features | keys | .[]' \
150+
| grep -v s3-test | sort | uniq | paste -s -d "," -`
151+
cargo test --features $ALL_FEATURES --locked
123152
124153
windows:
125154
runs-on: windows-2022
@@ -140,8 +169,7 @@ jobs:
140169
- name: Run tests
141170
run: |
142171
$env:VCPKG_ROOT = $env:VCPKG_INSTALLATION_ROOT
143-
cargo build
144-
cargo test
172+
cargo test --features remote --locked
145173
146174
windows-arm64:
147175
runs-on: windows-4x-arm
@@ -236,8 +264,7 @@ jobs:
236264
- name: Run tests
237265
run: |
238266
$env:VCPKG_ROOT = $env:VCPKG_INSTALLATION_ROOT
239-
cargo build --target aarch64-pc-windows-msvc
240-
cargo test --target aarch64-pc-windows-msvc
267+
cargo test --target aarch64-pc-windows-msvc --features remote --locked
241268
242269
msrv:
243270
# Check the minimum supported Rust version

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ venv
99
.vscode
1010
.zed
1111
rust/target
12-
rust/Cargo.lock
1312

1413
site
1514

@@ -42,5 +41,3 @@ dist
4241
target
4342

4443
**/sccache.log
45-
46-
Cargo.lock

0 commit comments

Comments
 (0)