Skip to content

ci: enable Rust build artifact caching in Python tests#143

Merged
beinan merged 7 commits into
lance-format:mainfrom
beinan:ci/fix-python-rust-cache
Feb 24, 2026
Merged

ci: enable Rust build artifact caching in Python tests#143
beinan merged 7 commits into
lance-format:mainfrom
beinan:ci/fix-python-rust-cache

Conversation

@beinan
Copy link
Copy Markdown
Collaborator

@beinan beinan commented Feb 18, 2026

Summary

Optimize CI workflows to dramatically reduce build times through improved caching and build configuration.

Changes

1. Shared Rust Dependency Cache

  • Added shared-key: "lance-graph-deps" to all workflows
  • Cache is shared across Python, Rust, Build, and Style workflows
  • Include both crates/lance-graph and crates/lance-graph-python workspaces
  • Prevents duplicate compilation across different workflows

2. Fix Double Rust Build in Python Tests

  • Removed uv pip install -e .[tests] which was triggering Rust compilation
  • Now only maturin develop builds the extension once
  • Result: 24 min → 6 min (74% faster!)

3. Remove Nightly from Rust Test Matrix

  • Only test on stable toolchain (matches upstream lance project)
  • Prevents nightly breakage from blocking PRs
  • Stable is the primary deployment target

4. Explicit CARGO_INCREMENTAL=0

  • Set explicitly for CI (rust-cache overrides to 0 anyway)
  • Makes intention clear: incremental artifacts not useful in CI

Performance Impact

Before:

  • Python Tests: ~24 minutes
  • Rust compiled twice (18min + 5min)
  • No cache sharing across workflows

After:

  • Python Tests: 6 minutes (74% faster)
  • Rust compiled once (5min)
  • Shared cache across all workflows

Test Results

All CI checks passing:

  • ✅ Python Tests (test 3.11) - 6 minutes
  • ✅ Rust Tests (stable)
  • ✅ Rust Coverage
  • ✅ Build (stable)
  • ✅ All Linters (clippy, format, Python lint, spell check)

🤖 Generated with Claude Code

beinan and others added 2 commits February 18, 2026 23:21
Fix Rust cache configuration to properly cache compiled artifacts.
This should significantly reduce the maturin develop step time in CI
by reusing cached builds when Rust code hasn't changed.

Changes:
- Set correct workspace path to crates/lance-graph-python
- Remove cache-targets: false to enable artifact caching (defaults to true)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Configure all workflows to share a single Rust dependency cache using
shared-key. This allows different workflows to reuse compiled artifacts
for dependencies like Arrow, DataFusion, Tokio, and aws-lc-sys.

Changes:
- Add shared-key: "lance-graph-deps" to all rust-cache configurations
- Include both crates/lance-graph and crates/lance-graph-python workspaces
- Remove cache-targets: false to enable target directory caching
- Apply to: python-test.yml, build.yml, rust-test.yml, style.yml

Expected impact:
- First workflow run compiles dependencies and populates shared cache
- Subsequent workflows (even different ones) reuse cached dependencies
- Massive time savings: 5+ min build → <1 min for unchanged dependencies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

beinan and others added 5 commits February 19, 2026 05:55
This trivial change will test if the shared Rust cache is working.
Expected: Build time should drop from 23min to <2min.
Root cause: CARGO_INCREMENTAL=0 was preventing cargo from reusing
any cached compilation artifacts, making rust-cache ineffective.

Setting CARGO_INCREMENTAL=1 allows cargo to:
- Reuse compiled .rlib files from cache
- Skip recompiling unchanged dependencies
- Dramatically reduce build times (5min -> <1min expected)

Applied to: python-test.yml, build.yml, rust-test.yml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Skip editable install during dependency setup to avoid building Rust
extension twice. The workflow was:
1. uv pip install -e .[tests] → builds Rust (18 min)
2. maturin develop → builds Rust again (5 min)

Now only maturin develop builds once, reducing CI time from 24min to ~6min.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove nightly toolchain testing to prevent upstream dependency breakage
from blocking PRs. This matches the upstream lance project's approach,
which only uses nightly for specific jobs (coverage).

Current issue: shellexpand v3.1.1 fails to compile on nightly Rust with
type mismatch errors. Since this is a transitive dependency, we cannot
fix it directly.

Benefits:
- Prevents nightly breakage from blocking PRs
- Follows upstream lance pattern
- Stable toolchain is the primary target anyway

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Set CARGO_INCREMENTAL=0 explicitly since rust-cache overrides it to 0
anyway. This makes the intention clear and matches the CI convention.

Incremental compilation artifacts are not useful in CI because:
- They're workspace-specific (only help with unchanged code)
- rust-cache only caches dependencies, not workspace code
- Workspace code changes every commit
- Creating incremental artifacts wastes time/space

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@beinan beinan merged commit acb4c25 into lance-format:main Feb 24, 2026
8 checks passed
beinan added a commit to lance-format/lance-context that referenced this pull request Mar 4, 2026
#43)

## Summary

Apply learnings from
[lance-graph#143](lance-format/lance-graph#143)
to dramatically improve CI performance. That PR achieved a **74% speedup
(24min → 6min)** in Python tests through better caching and eliminating
duplicate builds.

## Changes

### 1. Shared Rust Cache Across All Workflows ⭐
- Switched from manual `cache@v4` to `Swatinem/rust-cache@v2` 
- Added `shared-key: "lance-context-deps"` to all workflows
- **Impact**: Prevents duplicate compilation of Rust dependencies across
Python, Rust, and Style workflows
- Cache is now shared across all jobs instead of being isolated

### 2. Remove Nightly from Test Matrix
- Only test on `stable` toolchain (matches upstream lance project)
- **Impact**: ~50% reduction in Rust test time, prevents nightly
breakage from blocking PRs
- Stable is the primary deployment target

### 3. Standardize CARGO_INCREMENTAL=0
- Added to `python-test.yml` (was missing)
- Added to `style.yml` (was missing)  
- Already present in `rust-test.yml`
- **Impact**: Consistent CI environment, no wasted incremental
compilation artifacts

### 4. Optimized Cache Configuration
- Removed `CARGO_TARGET_DIR` override (rust-cache handles this better)
- Standardized workspaces across all workflows to include both
`crates/lance-context-core` and `python`
- **Impact**: Better cache hit rates and management

## Expected Performance Impact

Based on the improvements seen in lance-graph:
- ✅ Reduced duplicate Rust compilations via shared cache key
- ✅ Faster CI runs with streamlined test matrix  
- ✅ Better cache efficiency with rust-cache action
- ✅ Consistent build environment across all workflows

## Test Plan

- [x] All workflow files updated consistently
- [ ] Verify CI passes with new caching strategy
- [ ] Monitor CI times to confirm performance improvement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants