Skip to content

Commit ac2efa6

Browse files
bumahkib7claude
andcommitted
perf: add sccache, test sharding, and optimized profiles
Major CI/CD optimizations: 1. sccache integration - Shared compilation cache across all jobs - Uses GitHub Actions cache backend - Dramatically reduces compile times on cache hit 2. Test sharding (3 parallel runners) - Tests split across 3 runners using nextest partitioning - ~3x faster test execution - Each partition runs independently 3. Optimized Cargo profiles - dev: minimal debug info, incremental builds - dev.package.*: opt-level=1 for deps (faster tests) - ci: no debug info, no incremental (reliable caching) - release: added strip=true for smaller binaries 4. Release workflow improvements - sccache for native builds - Disabled sccache for cross builds (incompatible) - Cleaner matrix configuration with use_cross flag Expected improvements: - CI with warm cache: ~3-4 min (was ~15 min) - Release builds: 20-30% faster with sccache hits - Test execution: ~3x faster with sharding Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent c8905ec commit ac2efa6

File tree

3 files changed

+65
-28
lines changed

3 files changed

+65
-28
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
env:
1010
CARGO_TERM_COLOR: always
1111
RUST_BACKTRACE: 1
12+
SCCACHE_GHA_ENABLED: "true"
13+
RUSTC_WRAPPER: "sccache"
1214

1315
jobs:
1416
fmt:
@@ -31,55 +33,63 @@ jobs:
3133
- name: Install mold linker
3234
run: |
3335
sudo apt-get update && sudo apt-get install -y mold
36+
mkdir -p ~/.cargo
3437
echo '[target.x86_64-unknown-linux-gnu]' >> ~/.cargo/config.toml
3538
echo 'linker = "clang"' >> ~/.cargo/config.toml
3639
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> ~/.cargo/config.toml
3740
- name: Install Rust
3841
uses: dtolnay/rust-toolchain@stable
3942
with:
4043
components: clippy
41-
- name: Cache cargo
44+
- name: Setup sccache
45+
uses: mozilla-actions/[email protected]
46+
- name: Cache cargo registry
4247
uses: actions/cache@v4
4348
with:
4449
path: |
4550
~/.cargo/registry/index/
4651
~/.cargo/registry/cache/
4752
~/.cargo/git/db/
48-
target/
49-
key: cargo-clippy-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
53+
key: cargo-registry-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
5054
restore-keys: |
51-
cargo-clippy-${{ runner.os }}-
55+
cargo-registry-${{ runner.os }}-
5256
- name: Run clippy
5357
run: cargo clippy --all-targets --all-features -- -D warnings
5458

5559
test:
56-
name: Test Suite
60+
name: Test (${{ matrix.partition }}/3)
5761
runs-on: ubuntu-latest
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
partition: [1, 2, 3]
5866
steps:
5967
- uses: actions/checkout@v4
6068
- name: Install mold linker
6169
run: |
6270
sudo apt-get update && sudo apt-get install -y mold
71+
mkdir -p ~/.cargo
6372
echo '[target.x86_64-unknown-linux-gnu]' >> ~/.cargo/config.toml
6473
echo 'linker = "clang"' >> ~/.cargo/config.toml
6574
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> ~/.cargo/config.toml
6675
- name: Install Rust
6776
uses: dtolnay/rust-toolchain@stable
68-
- name: Cache cargo
77+
- name: Setup sccache
78+
uses: mozilla-actions/[email protected]
79+
- name: Cache cargo registry
6980
uses: actions/cache@v4
7081
with:
7182
path: |
7283
~/.cargo/registry/index/
7384
~/.cargo/registry/cache/
7485
~/.cargo/git/db/
75-
target/
76-
key: cargo-test-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
86+
key: cargo-registry-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
7787
restore-keys: |
78-
cargo-test-${{ runner.os }}-
88+
cargo-registry-${{ runner.os }}-
7989
- name: Install nextest
8090
uses: taiki-e/install-action@nextest
81-
- name: Run tests
82-
run: cargo nextest run --workspace
91+
- name: Run tests (partition ${{ matrix.partition }}/3)
92+
run: cargo nextest run --workspace --partition count:${{ matrix.partition }}/3
8393

8494
build:
8595
name: Build Release
@@ -90,22 +100,24 @@ jobs:
90100
- name: Install mold linker
91101
run: |
92102
sudo apt-get update && sudo apt-get install -y mold
103+
mkdir -p ~/.cargo
93104
echo '[target.x86_64-unknown-linux-gnu]' >> ~/.cargo/config.toml
94105
echo 'linker = "clang"' >> ~/.cargo/config.toml
95106
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> ~/.cargo/config.toml
96107
- name: Install Rust
97108
uses: dtolnay/rust-toolchain@stable
98-
- name: Cache cargo
109+
- name: Setup sccache
110+
uses: mozilla-actions/[email protected]
111+
- name: Cache cargo registry
99112
uses: actions/cache@v4
100113
with:
101114
path: |
102115
~/.cargo/registry/index/
103116
~/.cargo/registry/cache/
104117
~/.cargo/git/db/
105-
target/
106-
key: cargo-build-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
118+
key: cargo-registry-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
107119
restore-keys: |
108-
cargo-build-${{ runner.os }}-
120+
cargo-registry-${{ runner.os }}-
109121
- name: Build release
110122
run: cargo build --release
111123

.github/workflows/release.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ permissions:
1111

1212
env:
1313
CARGO_TERM_COLOR: always
14+
SCCACHE_GHA_ENABLED: "true"
15+
RUSTC_WRAPPER: "sccache"
1416

1517
jobs:
1618
build:
@@ -24,6 +26,7 @@ jobs:
2426
os: ubuntu-latest
2527
- target: aarch64-unknown-linux-gnu
2628
os: ubuntu-latest
29+
use_cross: true
2730
- target: x86_64-apple-darwin
2831
os: macos-latest
2932
- target: aarch64-apple-darwin
@@ -43,6 +46,10 @@ jobs:
4346
with:
4447
targets: ${{ matrix.target }}
4548

49+
- name: Setup sccache
50+
if: matrix.use_cross != true
51+
uses: mozilla-actions/[email protected]
52+
4653
- name: Cache cargo registry
4754
uses: actions/cache@v4
4855
with:
@@ -54,34 +61,30 @@ jobs:
5461
restore-keys: |
5562
cargo-registry-${{ runner.os }}-
5663
57-
- name: Cache cargo build
58-
uses: actions/cache@v4
59-
with:
60-
path: target
61-
key: cargo-build-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
62-
restore-keys: |
63-
cargo-build-${{ matrix.target }}-
64-
6564
- name: Cache cross
66-
if: matrix.target == 'aarch64-unknown-linux-gnu'
65+
if: matrix.use_cross == true
6766
uses: actions/cache@v4
6867
with:
6968
path: ~/.cargo/bin/cross
7069
key: cross-${{ runner.os }}-v0.2
7170

7271
- name: Install cross
73-
if: matrix.target == 'aarch64-unknown-linux-gnu'
72+
if: matrix.use_cross == true
73+
env:
74+
RUSTC_WRAPPER: ""
7475
run: |
7576
if [ ! -f ~/.cargo/bin/cross ]; then
7677
cargo install cross --git https://github.com/cross-rs/cross
7778
fi
7879
7980
- name: Build (cross)
80-
if: matrix.target == 'aarch64-unknown-linux-gnu'
81+
if: matrix.use_cross == true
82+
env:
83+
RUSTC_WRAPPER: ""
8184
run: cross build --release --target ${{ matrix.target }}
8285

8386
- name: Install mold linker (Linux)
84-
if: runner.os == 'Linux' && matrix.target != 'aarch64-unknown-linux-gnu'
87+
if: runner.os == 'Linux' && matrix.use_cross != true
8588
run: |
8689
sudo apt-get update && sudo apt-get install -y mold
8790
mkdir -p ~/.cargo
@@ -90,7 +93,7 @@ jobs:
9093
echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold"]' >> ~/.cargo/config.toml
9194
9295
- name: Build (native)
93-
if: matrix.target != 'aarch64-unknown-linux-gnu'
96+
if: matrix.use_cross != true
9497
run: cargo build --release --target ${{ matrix.target }}
9598

9699
- name: Package (Unix)
@@ -139,6 +142,8 @@ jobs:
139142
name: Publish to crates.io
140143
needs: release
141144
runs-on: ubuntu-latest
145+
env:
146+
RUSTC_WRAPPER: ""
142147
steps:
143148
- uses: actions/checkout@v4
144149

Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,30 @@ comfy-table = "7.1"
105105
chrono = "0.4"
106106
dirs = "6.0"
107107

108+
# Dev profile: optimize for fast compile times
109+
[profile.dev]
110+
opt-level = 0
111+
debug = 1 # Minimal debug info (faster)
112+
split-debuginfo = "unpacked" # Faster incremental builds
113+
incremental = true
114+
115+
# Dev dependencies: compile with some optimization for faster tests
116+
[profile.dev.package."*"]
117+
opt-level = 1
118+
119+
# CI profile: balance between compile time and runtime
120+
[profile.ci]
121+
inherits = "dev"
122+
opt-level = 1
123+
debug = 0 # No debug info in CI
124+
incremental = false # More reliable caching
125+
126+
# Release profile: maximum optimization
108127
[profile.release]
109128
lto = "thin"
110129
codegen-units = 1
111130
panic = "abort"
131+
strip = true # Strip symbols for smaller binary
112132

113133
[profile.bench]
114134
lto = "thin"

0 commit comments

Comments
 (0)