Optimize Rust CI builds with proper sccache configuration (#15581)
This commit is contained in:
@@ -40,7 +40,7 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
@@ -159,7 +159,7 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
@@ -226,7 +226,7 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ concurrency:
|
|||||||
group: test-disaggregation-${{ github.ref }}
|
group: test-disaggregation-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
RUSTC_WRAPPER: sccache
|
||||||
|
SCCACHE_GHA_ENABLED: "true"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
@@ -50,18 +54,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
bash scripts/ci/ci_install_rust.sh
|
bash scripts/ci/ci_install_rust.sh
|
||||||
|
|
||||||
- name: Cache Rust dependencies
|
- name: Configure sccache
|
||||||
uses: actions/cache@v4
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
path: |
|
version: "v0.12.0"
|
||||||
~/.cargo/bin/
|
|
||||||
~/.cargo/registry/index/
|
- name: Rust cache
|
||||||
~/.cargo/registry/cache/
|
uses: Swatinem/rust-cache@v2
|
||||||
~/.cargo/git/db/
|
with:
|
||||||
sgl-model-gateway/target/
|
workspaces: sgl-model-gateway
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('sgl-model-gateway/Cargo.lock') }}
|
shared-key: "rust-cache"
|
||||||
restore-keys: |
|
cache-all-crates: true
|
||||||
${{ runner.os }}-cargo-
|
cache-on-failure: true
|
||||||
|
save-if: true
|
||||||
|
|
||||||
- name: Cache pip dependencies
|
- name: Cache pip dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
|
|||||||
@@ -55,7 +55,16 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
|
- name: Rust cache
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
workspaces: "."
|
||||||
|
shared-key: "rust-cache"
|
||||||
|
cache-all-crates: true
|
||||||
|
cache-on-failure: true
|
||||||
|
save-if: true
|
||||||
|
|
||||||
- name: Test maturin build
|
- name: Test maturin build
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
@@ -91,14 +100,16 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: sgl-model-gateway
|
workspaces: sgl-model-gateway
|
||||||
|
shared-key: "rust-cache"
|
||||||
cache-all-crates: true
|
cache-all-crates: true
|
||||||
cache-on-failure: true
|
cache-on-failure: true
|
||||||
|
save-if: true
|
||||||
|
|
||||||
- name: Run lint
|
- name: Run lint
|
||||||
run: |
|
run: |
|
||||||
@@ -153,14 +164,16 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: sgl-model-gateway
|
workspaces: sgl-model-gateway
|
||||||
|
shared-key: "rust-cache"
|
||||||
cache-all-crates: true
|
cache-all-crates: true
|
||||||
cache-on-failure: true
|
cache-on-failure: true
|
||||||
|
save-if: true
|
||||||
|
|
||||||
- name: Install SGLang dependencies
|
- name: Install SGLang dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -225,14 +238,16 @@ jobs:
|
|||||||
- name: Configure sccache
|
- name: Configure sccache
|
||||||
uses: mozilla-actions/sccache-action@v0.0.9
|
uses: mozilla-actions/sccache-action@v0.0.9
|
||||||
with:
|
with:
|
||||||
version: "v0.10.0"
|
version: "v0.12.0"
|
||||||
|
|
||||||
- name: Rust cache
|
- name: Rust cache
|
||||||
uses: Swatinem/rust-cache@v2
|
uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
workspaces: sgl-model-gateway
|
workspaces: sgl-model-gateway
|
||||||
|
shared-key: "rust-cache"
|
||||||
cache-all-crates: true
|
cache-all-crates: true
|
||||||
cache-on-failure: true
|
cache-on-failure: true
|
||||||
|
save-if: true
|
||||||
|
|
||||||
- name: Install SGLang dependencies
|
- name: Install SGLang dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -625,6 +625,27 @@ pytest py_test/
|
|||||||
```
|
```
|
||||||
For production builds, use `maturin build --release --out dist` from the `bindings/python/` directory to create optimized wheels. During development, `maturin develop` rebuilds and installs instantly without creating wheel files. Use `python -m sglang_router.launch_server` to co-launch router and SGLang workers in small clusters for local validation.
|
For production builds, use `maturin build --release --out dist` from the `bindings/python/` directory to create optimized wheels. During development, `maturin develop` rebuilds and installs instantly without creating wheel files. Use `python -m sglang_router.launch_server` to co-launch router and SGLang workers in small clusters for local validation.
|
||||||
|
|
||||||
|
### Build Caching
|
||||||
|
|
||||||
|
**Local development** uses incremental compilation by default (configured in `.cargo/config.toml`), which is optimal for the edit-compile-test cycle.
|
||||||
|
|
||||||
|
**For release builds or CI**, you can optionally use [sccache](https://github.com/mozilla/sccache) to cache compilation artifacts:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install sccache
|
||||||
|
cargo install sccache
|
||||||
|
|
||||||
|
# Option 1: Set environment variable (per-session)
|
||||||
|
export RUSTC_WRAPPER=sccache
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
# Option 2: Add to your global cargo config (~/.cargo/config.toml)
|
||||||
|
# [build]
|
||||||
|
# rustc-wrapper = "sccache"
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** sccache and incremental compilation are mutually exclusive—sccache cannot cache incrementally compiled crates. The project defaults to incremental compilation for faster local iteration. Use sccache for clean/release builds where caching across builds matters more.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Release Management
|
## Release Management
|
||||||
|
|||||||
Reference in New Issue
Block a user