Skip to content

rust: reuse dep-info and output lists across compiles of a crate - #2942

Open
sylvestre wants to merge 1 commit into
preprocessor-entry-decodefrom
rust-direct-mode
Open

sylvestre wants to merge 1 commit into
preprocessor-entry-decodefrom
rust-direct-mode

Conversation

@sylvestre

@sylvestre sylvestre commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

rust: reuse dep-info and output lists across compiles of a crate

To compute the cache key of a crate, sccache runs rustc --emit=dep-info
to list its source files and env-deps, and rustc --print file-names to
list its outputs, even when the compile then hits the cache. The first one
parses and expands the whole crate, proc macros included, and was most of
the work of a Rust cache hit.

The server now remembers what both runs found, and reuses it for a later
compile with the same compiler, arguments, working directory, environment,
externs, static libraries and target spec, as long as every listed source
file still has the same digest and every env-dep the same value. The whole
environment is part of that key, except the jobserver variables, so that a
proc macro picking its inputs from an untracked variable can only cause a
miss. Entries live for the life of the server; nothing is written to the
cache.

All-hits debug build of sccache (332 Rust crates):
wall: 5.7 s -> 3.9 s
server-side CPU, including the rustc it runs: 26.3 s -> 4.1 s

@sylvestre
sylvestre added this pull request to stack #2944 October 24, 2026 13:02
@codecov-commenter

codecov-commenter commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.11321% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.68%. Comparing base (4c9ad47) to head (4e4f932).

Files with missing lines Patch % Lines
src/compiler/rust.rs 98.11% 4 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           preprocessor-entry-decode    #2942      +/-   ##
=============================================================
+ Coverage                      78.60%   78.68%   +0.07%     
=============================================================
  Files                             74       74              
  Lines                          44179    44364     +185     
=============================================================
+ Hits                           34728    34908     +180     
- Misses                          9451     9456       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sylvestre
sylvestre force-pushed the rust-direct-mode branch 2 times, most recently from 3803310 to 0990e77 Compare October 25, 2026 08:52
@sylvestre
sylvestre marked this pull request as ready for review October 25, 2026 08:56
@sylvestre
sylvestre removed this pull request from stack #2944 October 25, 2026 13:14
@sylvestre
sylvestre added this pull request to stack #2952 October 25, 2026 13:14
@sylvestre
sylvestre force-pushed the rust-direct-mode branch 2 times, most recently from e012b60 to b35987c Compare October 25, 2026 22:08
To compute the cache key of a crate, sccache runs `rustc --emit=dep-info`
to list its source files and env-deps, and `rustc --print file-names` to
list its outputs, even when the compile then hits the cache. The first one
parses and expands the whole crate, proc macros included, and was most of
the work of a Rust cache hit.

The server now remembers what both runs found, and reuses it for a later
compile with the same compiler, arguments, working directory, environment,
externs, static libraries and target spec, as long as every listed source
file still has the same digest and every env-dep the same value. The whole
environment is part of that key, except the jobserver variables, so that a
proc macro picking its inputs from an untracked variable can only cause a
miss. Entries live for the life of the server; nothing is written to the
cache.

All-hits debug build of sccache (332 Rust crates):
  wall:                     5.7 s -> 3.9 s
  server-side CPU, including the rustc it runs: 26.3 s -> 4.1 s
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.

2 participants