Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upcargo ./target fills with outdated artifacts as toolchains are updated/changed #5026
Comments
This comment has been minimized.
This comment has been minimized.
|
This is currently a feature of Cargo that it aggressively caches, but we could always add a comment to delete otherwise stale artifacts! |
This comment has been minimized.
This comment has been minimized.
|
Yes, I don't think the current behaviour is wrong. It would just be nice to able to say "get rid of the old cached stuff now, I'm not going back to rust 1.22 any time soon". Particularly for things like Rls where we can expect users to update the toolchain fairly often, but don't really inform them about cleaning |
alexcrichton
added
the
C-feature-request
label
Feb 9, 2018
This comment has been minimized.
This comment has been minimized.
seanmonstar
commented
Feb 17, 2018
|
Since I always develop on nightly, this is true every day. I'm kind of in the habit now of deleting However, it seems like this also affects the cache used by Travis CI, as noted in seanmonstar/reqwest#259 |
This comment has been minimized.
This comment has been minimized.
|
I've experienced this problem both for local development and in Travis. For example, my Travis CI cache has 56 copies of every dependency; sometimes the dependency is updated and sometimes the compiler is updated. For one crate I looked at, each build was 250K. In total, my cache weighed in at 1.4 GB. This caused the cache to take about 7-9 minutes to download and upload, compared to a build time of ~2 minutes! Some of that cache is from other parts of the build, but after clearing the cache and rebuilding, it's only ~175MB. Roughly 1.2 GB of the Travis cache was composed of these build artifacts. I also primarily locally develop using nightly, and often find my laptop's disk running out of space because of multiple outdated gigabytes worth of build artifacts. I agree that A potential second step would be to do a bit of inspection during a build to note that there are (many? / large?) artifacts lying around that were not used and warn the user about them. A future thing would be akin to git's garbage collection, where unused artifacts older than some date are just automatically removed. |
ehuss
referenced this issue
Mar 16, 2018
Closed
build files from before `rustup update` are not deleted. #5194
dwijnand
added
the
Command-clean
label
Sep 16, 2018
dwijnand
referenced this issue
Sep 28, 2018
Closed
Cargo doesn't clean build artifacts from old nighlies #5516
This comment has been minimized.
This comment has been minimized.
|
Aside from CI, how common is switching compilers for a given project? I feel like it's not very common. Can we have an on-by-default pref that specifies whether or not these things are deleted? Travis's image can turn the pref off. We can also implement something where we record whenever an artifact was last used, and unnecessary artifacts that haven't been touched for a couple days get deleted. But I'd rather go the flat deletion route. |
This comment has been minimized.
This comment has been minimized.
Ideally it happens every 6 weeks at a minimum (stable), or perhaps every few days (nightly). |
This comment has been minimized.
This comment has been minimized.
|
I mean, switching back and forth between compilers. If you update your stable or nightly you don't need the old artifacts anymore. It's only an issue if you're switching back and forth, which I feel is rare. |
This comment has been minimized.
This comment has been minimized.
|
Switching between current stable and current nightly is at least fairly common. |
This comment has been minimized.
This comment has been minimized.
|
Off of CI? I find that a bit hard to believe. Either way, this would at least work as a preference, preferably on by default. |
alexheretic
changed the title
cargo target fills will outdated artifacts as toolchains are updated/changed
cargo ./target fills with outdated artifacts as toolchains are updated/changed
Sep 29, 2018
This comment has been minimized.
This comment has been minimized.
yory8
commented
Sep 30, 2018
probably only before clippy was in stable, though |
This comment has been minimized.
This comment has been minimized.
|
I was thinking of cargo dev, actually. Perhaps it's more niche than I thought. |
This comment has been minimized.
This comment has been minimized.
|
I think a very recurring problem we have is that the use cases best
represented on these issue trackers are those of compiler/tool hackers,
which are in a minority otherwise.
cargo dev is definitely a niche use case :)
…On Sun, Sep 30, 2018, 12:13 PM Dale Wijnand ***@***.***> wrote:
I was thinking of cargo dev, actually. Perhaps it's more niche than I
thought.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5026 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABivSDskcMScFwjlNVSmWxMOm27qFvoKks5ugJlWgaJpZM4R_ye4>
.
|
This comment has been minimized.
This comment has been minimized.
dbaron
commented
Sep 30, 2018
|
My hopefully slightly-less-niche use case was that I'd built software in rust that runs on a server (in my case, an IRC bot that I run on a VM in AWS), set up a cron job to keep the rust compiler up-to-date ( |
This comment has been minimized.
This comment has been minimized.
|
To put in two cents from a non-compiler person, I do a lot of cross compiling, and I'd like for the caching to be more aggressive. Maybe a |
This comment has been minimized.
This comment has been minimized.
|
I feel like that's an orthogonal problem -- cargo check should be able to reuse metadata from already compiled crates -- it just doesn't. If I don't think what I'm proposing here affects your use case at all -- I'm proposing cleaning up after compiler upgrades, cargo check works differently. It's imperfect but it's not made worse by this proposal. |
This comment has been minimized.
This comment has been minimized.
Specifically it's #3501 |
icefoxen
referenced this issue
Oct 27, 2018
Open
Have an option to make Cargo attempt to clean up after itself. #6229
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton i might try and implement this, do you have any pointers as to what I should look at? |
This comment has been minimized.
This comment has been minimized.
|
It sort of depends on the method of implementing, but it'd likely all be around |
This comment has been minimized.
This comment has been minimized.
|
Just a rough idea: One option is to completely remove rustc from the metadata hash (here). It is still included in the fingerprint, so when rustc changes cargo will recompile everything. A more ambitious approach would be to make it so that you can keep multiple release channels cached at the same time. This would require extracting the channel from the version information and only including that in the metadata ("stable", "beta", "nightly"). The version string doesn't explicitly include the channel, so it might take some rough interpretation. Also, I would be very careful to very fully test things in the rustc repo. Since it builds with multiple stages, I would double check that it won't suddenly start clobbering artifacts. There are some tricky issues involving I don't know if this approach will work, but offhand I can't think of any major issues. I'm not sure how good rustc itself is at cleaning up its incremental directory and dealing with reusing it across versions. |
This comment has been minimized.
This comment has been minimized.
Hi-Angel
commented
Jan 20, 2019
|
I want to add another problem that these artifacts are causing. It's that the generated code usually ends up somewhere down the |
alexheretic commentedFeb 9, 2018
cargo has to recompile dependencies once a toolchain has updated/changed, this leaves all previous artifacts intact. However, this means when you're updating toolchains the target dir will just grow and grow.
Currently you can
cargo cleanand rebuild, but it would be nice to be able to clean only the dependencies that are not compatible for the current toolchain. Perhapscargo clean --incompatible?For example building a small crate
This can obviously be much more problematic on larger crates.