gc: track and clean target directories#16929
gc: track and clean target directories#16929tomsanbear wants to merge 5 commits intorust-lang:masterfrom
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
The issue for this is #13136. Since that issue, we now have the concept of build-dir in addition to target-dir which may overlap or be independent. There was a previous attempt at #13846 that would be good to compare notes with. Our contrib guide asks for a specific organization of commits, see https://doc.crates.io/contrib/process/working-on-cargo.html#submitting-a-pull-request. I've written more on each of those points at https://epage.github.io/dev/pr-style/. We haven't yet decided whether to integrate that into our docs. I'd particularly like to call out |
| let to_build_ids = resolve.specs_to_ids(&specs)?; | ||
| { | ||
| let mut deferred = gctx.deferred_global_last_use()?; | ||
| let target_dir_path = paths::normalize_path(&ws.target_dir().into_path_unlocked()); |
There was a problem hiding this comment.
Looking up the target and build dirs can involve a bit of work. Might be good to check the Layout.
|
It would be good to discuss your database schema in the PR description. |
|
Thanks, I dug into the current From the current workspace logic, Since this is my first contribution here, I would rather err on the side of |
I'd recommend looking back over this because hat is not correct. |
132e261 to
1881e02
Compare
Hmm, okay, I'll take another look. In the meantime, do you have any feeling regarding the inclusion of this within the scope to be covered within this pull request? |
What does this PR try to resolve?
Part of #13136.
This implements target-directory last-use tracking and
cargo clean gc -Zgccleanup fortarget/directories.The main fix is to make target-dir GC operate on physical target directories instead of individual database rows, which is necessary for shared
CARGO_TARGET_DIRsetups.This follows the design in #13136 by storing target-dir associations as
(workspace_manifest, target_dir)rows in a singletarget_directorytable.That supports both shared target dirs across workspaces and multiple target dirs for one workspace.
This PR also:
CACHEDIR.TAGtarget_directorymigration at the end of the migration listHow to test and review this PR?
Review the changes in:
src/cargo/ops/cargo_compile/mod.rssrc/cargo/core/global_cache_tracker.rstests/testsuite/global_cache_tracker.rsTests run:
tests/testsuite/global_cache_tracker.rscargo test --test testsuite -- global_cache_tracker:: --quietThe broader slice still hits the pre-existing
global_cache_tracker::read_only_locking_auto_gcfailure, which also reproduces on master.