Skip to content

perf(ci): add Cargo caching to Rust CI jobs#3431

Open
moon3482 wants to merge 1 commit intoapache:mainfrom
moon3482:feat/add-cargo-cache
Open

perf(ci): add Cargo caching to Rust CI jobs#3431
moon3482 wants to merge 1 commit intoapache:mainfrom
moon3482:feat/add-cargo-cache

Conversation

@moon3482
Copy link

@moon3482 moon3482 commented Feb 27, 2026

Why?

The Rust CI currently takes approximately 3-5 minutes to complete. By adding Cargo dependency caching, we can reduce build times by caching compiled dependencies between runs.

What does this PR do?

  • Adds Swatinem/rust-cache@v2 to the rust job in .github/workflows/ci.yml
  • Adds Swatinem/rust-cache@v2 to the rust_xlang job in .github/workflows/ci.yml
  • Configures cache to use the rust workspace directory

Related issues

Closes #2889

Does this PR introduce any user-facing change?

No user-facing changes. This only affects CI execution time.

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

CI execution time comparison:

Job Before (main) After (with cache) Improvement
Rust CI (ubuntu-latest) 3m 13s 2m 54s -19s
Rust CI (macos-14) 3m 02s 2m 53s -9s
Rust CI (macos-latest) 3m 16s 3m 22s ⚠️ +6s

Cache details:

  • Cache size: ~14MB
  • Cache includes: ~/.cargo/bin, ~/.cargo/registry, ~/.cargo/git, rust/target
  • Logs confirm: Cache restored successfully with full match
  • Cache key format: v0-rust-rust-Linux-x64-<env-hash>-<lockfile-hash>

Notes:

  • Ubuntu shows consistent improvement (~19s faster)
  • macOS results are within normal variance range for GitHub Actions runners
  • Cache prevents re-downloading and re-compiling Rust dependencies on subsequent runs

Add Swatinem/rust-cache@v2 to rust and rust_xlang jobs to reduce CI execution time.

Related to apache#2889
@moon3482 moon3482 force-pushed the feat/add-cargo-cache branch from f33c9dc to 7740dc2 Compare February 27, 2026 15:41
@moon3482 moon3482 marked this pull request as ready for review February 27, 2026 15:43
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.

[Rust] Optimize Rust CI execution speed by cache cargo

1 participant