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 upHow to effectively clean target folder for CI caching #5885
Comments
This comment has been minimized.
This comment has been minimized.
|
Thanks for the report! Right now there's not a great answer here in that Cargo doesn't have anything implemented to do something like this nor does it internally support the ability to know which artifacts are super old. Currently I'd recommend using something like |
alexcrichton
added
the
C-feature-request
label
Aug 14, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks for the quick answer! |
This comment has been minimized.
This comment has been minimized.
|
For posterity: in my .travis.ci, in This seems to greatly speed-up CI builds. I wonder if we can make caching easier by adding more structure to the |
This comment has been minimized.
This comment has been minimized.
|
Thanks for sharing! l I've tried something like this already.
The problem is that our project is a workspace and things are not that easy
then. Many crates depend on each other and thus cause many workspace
related artifacts in `target/` - impossible to delete so that the cache is
not poisoned.
For now, we use sccache with the local directory cache and only put that
into the travis cache. We don't cache the target folder at all.
Works reasonably well so far.
…On Thu, 25 Oct 2018, 03:14 Aleksey Kladov, ***@***.***> wrote:
For posterity: in my .travis.ci, in before_cache, I try to explicitly
delete artifacts for current workspace, while keeping artifacts from the
deps intact:
https://github.com/rust-analyzer/rust-analyzer/blob/9a7db8fa009c612168ef16f6ed72315b5406ed09/.travis.yml#L2-L4
This seems to greatly speed-up CI builds. I wonder if we can make caching
easier by adding more structure to the target dir? If, for example, we
group artifacts into folders based on source_id, then it should be easy to
purge anything not from crates.io.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#5885 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFO3NbwV0lCzFfeQotYWY3Vl6gmY7znZks5uoJHUgaJpZM4V6UfN>
.
|
matklad
referenced this issue
Oct 30, 2018
Closed
Investigate using sccache with local disc cache on CI #174
This comment has been minimized.
This comment has been minimized.
|
So, I've been using the https://travis-ci.org/rust-analyzer/rust-analyzer/jobs/463540847 One interesting bit is compilation:
This is awesome, considering the fact that rust-analyzer has 145 dependencies, two of which are Another interesting bit is cache uploading:
I think such caching strategy may make a huge difference for project which build/gate on stable (nightly is trickier, because cache will die with the next nightly). In terms of cost/benefit, I think adding a small help from the Cargo's side (dumping all deps from crates.io source to a separate cachable dir) will be very welcome here. cc @rust-lang/cargo: perhaps I am overly enthusiastic here, but it does look like a low-hanging watermelon :) |
This comment has been minimized.
This comment has been minimized.
|
I don't think there's any disagreement that Cargo can do a lot here, just needs someone to help push through a design! |
This comment has been minimized.
This comment has been minimized.
|
Made a rough POC here: matklad@b3566b1 It was harder then anticipated, mainly because we have three different dirs we need to account for: The real implementation should probably transpose the order of directories:
so that you can point CI cache to However, with this design, if we then allow overriding the location of |
Eh2406
referenced this issue
Dec 6, 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.
|
Does this also account/work for workspaces? We have had the biggest problems with workspaces because local crates depend on each other and that causes a weird structure inside the target folder. Nice that this is being worked on! :) |
This comment has been minimized.
This comment has been minimized.
|
I don't know how the files are currently laid out, so my opinion should come with a big helping of salt, it would be lovely to have the rust version in the path for artifacts that can only be used by that version of rust. That would make it straightforward to make a GC that dells artifacts that are for a version of rust that are no longer installed. This is not mutually exclusive with other information being encoded in the path, or stored in some other format (like a timestamp file). |
This comment has been minimized.
This comment has been minimized.
|
cc crates.io having trouble with this. |
This comment has been minimized.
This comment has been minimized.
|
Found something that might be useful in this regard: |
thomaseizinger commentedAug 13, 2018
•
edited
I have a workspace repository with several crates in it (> 10). A clean build of all of them takes about 10 minutes on Travis, which is why I want to cache the
target/folder.The problem is, the target folder gets quite big (~ 1.7GB) so it takes also about 3 minutes to upload the cache to S3 after the build.
The question is: How can I clean the
targetfolder from any artifacts generated by my own code?If I can achieve that, then the
targetfolder would only have the artifacts of all the dependencies in it. As long as they don't change, Travis would not have to re-upload the cache. At the same time, rebuilding only the workspace crates takes only 30 seconds.I have already tried several things:
cargo clean -pfor every workspace packagetargetthat mention a workspace crate's nameNone of the above were enough in order to get the
targetfolder into a state where NOTHING changes between two builds.I couldn't really understand the layout of the
targetfolder: The artifacts of dependencies seem to be mixed up with those of the workspace crates. Is there some documentation available on how the target folder is structured?