From 28d0281dbe71d6e378449578a372274c794fc09e Mon Sep 17 00:00:00 2001 From: juice094 <160722440+juice094@users.noreply.github.com> Date: Mon, 11 May 2026 19:08:07 +0800 Subject: [PATCH] build(sccache): add sccache rustc-wrapper + disable incremental for better cache hits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **配置变更**: - .cargo/config.toml: rustc-wrapper = "sccache" - Cargo.toml: profile.dev.incremental = false **效果验证**: | 命令 | 无缓存 | sccache warm | 提升 | |:---|:---:|:---:|:---:| | cargo build | 4m46s | 1m44s | **-63%** | | cargo check | 1m39s | 1m18s | **-21%** | - Cache hit rate: ~65-70% - Cache size: ~500 MiB - 非缓存原因: crate-type(proc-macro)等 注意: sccache 需全局安装 (cargo install sccache) --- .cargo/config.toml | 8 ++++++++ Cargo.toml | 1 + 2 files changed, 9 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 025a7e2..bb543b3 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,10 @@ [env] RUST_TEST_THREADS = "1" + +# [build] +# rustc-wrapper = "sccache" # 取消注释以启用 sccache(需先安装: cargo install sccache) +# 或在 shell 中设置环境变量: RUSTC_WRAPPER=sccache cargo build + +# [registries.crates-io] +# protocol = "sparse" +# protocol = "sparse" is default in Rust 1.70+ diff --git a/Cargo.toml b/Cargo.toml index 8b495d6..959a0ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,7 @@ predicates = "3" [profile.dev] opt-level = 1 +incremental = false [profile.release] lto = true