Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust and incremental compilation #236

Open
alexcrichton opened this issue Mar 14, 2018 · 6 comments
Open

Rust and incremental compilation #236

alexcrichton opened this issue Mar 14, 2018 · 6 comments

Comments

@alexcrichton
Copy link
Contributor

With the advent of incremental compilation on stable Rust compile times will hopefully get much better especially in debug mode and hopefully eventually in release mode with rust-lang/rust#48996. Ideally sccache would help to integrate with incremental compilation to even further accelerate CI and builds whenever possible!

Unfortunately it's not super clear how sccache would integrate with incremental compilation in Rust. There will never be an exact cache hit as sccache already otherwise does that, so we sort of need an "almost cache hit" to load something from the cache. One possible idea may be to hash fewer things and upload full compiler incremental cache directories. That way sccache would download the previous cache directory and let rustc take care of what should be reset.

In any case this isn't super pressing for now as incremental for release builds is still aways out, but figured I'd open an issue!

@luser
Copy link
Contributor

luser commented Mar 14, 2018

I had asked about this a while back when I was doing the Rust work initially but I think incremental compilation was still new enough that I couldn't get a useful answer. It would definitely be interesting to figure out a smart plan here. Maybe the simplest thing we could do would be to store the incremental compilation outputs in the cache entry, so that if you get a full cache hit you can at least do an incremental compile on top of that if you make changes?

You and @michaelwoerister and I should find time at the SF All Hands in June to chat about this.

@alexcrichton
Copy link
Contributor Author

Maybe the simplest thing we could do would be to store the incremental compilation outputs in the cache entry, so that if you get a full cache hit you can at least do an incremental compile on top of that if you make changes?

For sure! That I think sounds like a great idea and is quite possible to do with -C incremental=.. I think. (in that sccache would recognize such an argument, parse it, and slurp it up)

Unfortunately though I won't actually be at the SF All Hands, but @michaelwoerister if you've got a spare moment in the near future I'd love to chat with you about your thoughts on this :)

@michaelwoerister
Copy link
Contributor

Maybe the simplest thing we could do would be to store the incremental compilation outputs in the cache entry, so that if you get a full cache hit you can at least do an incremental compile on top of that if you make changes?

Yes, that should work. It will at least double the amount of data to download though. We'd also need to review if there's anything non-portable in the cache files (i.e. local file paths or something).

@luser
Copy link
Contributor

luser commented Mar 15, 2018

Yes, that should work. It will at least double the amount of data to download though. We'd also need to review if there's anything non-portable in the cache files (i.e. local file paths or something).

sccache doesn't currently get cache hits if file paths change (#196), so this isn't any worse than the current situation.

luser added a commit to luser/sccache that referenced this issue Jul 3, 2018
…#257

rustc's incremental compilation mode isn't well-handled by sccache currently
because we don't cache the separate artifacts it creates. Additionally,
if there are existing incremental artifacts it's likely that rustc will do
a better job than sccache anyway, so don't bother trying to cache Rust
compilation when incremental compilation is enabled for now.

Longer-term we would like to make sccache and rustc incremental work
together nicely: mozilla#236
luser added a commit that referenced this issue Jul 11, 2018
rustc's incremental compilation mode isn't well-handled by sccache currently
because we don't cache the separate artifacts it creates. Additionally,
if there are existing incremental artifacts it's likely that rustc will do
a better job than sccache anyway, so don't bother trying to cache Rust
compilation when incremental compilation is enabled for now.

Longer-term we would like to make sccache and rustc incremental work
together nicely: #236
aidanhs pushed a commit to aidanhs/sccache that referenced this issue Aug 6, 2018
…#257

rustc's incremental compilation mode isn't well-handled by sccache currently
because we don't cache the separate artifacts it creates. Additionally,
if there are existing incremental artifacts it's likely that rustc will do
a better job than sccache anyway, so don't bother trying to cache Rust
compilation when incremental compilation is enabled for now.

Longer-term we would like to make sccache and rustc incremental work
together nicely: mozilla#236
@jakelee8
Copy link
Contributor

@Xuanwo What do you think about supporting Rust incremental builds or disabling incremental compilation (by default or only for crate libraries)?

Caveat docs:

  1. https://github.com/mozilla/sccache#rust
  2. https://github.com/mozilla/sccache/blob/main/docs/Rust.md

@WieeRd
Copy link

WieeRd commented May 10, 2024

I'm a little confused about this caveat, does this mean I need to disable incremental build completely and globally via build.incremental option in ~/.cargo/config.toml if I want to benefit from cached builds?
My primary reason for using sccache is to share 3rd party dependency build caches between projects on my desktop.

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

No branches or pull requests

5 participants