feat(gc): record workspace manifest and target dir in global cache tracker#13846
feat(gc): record workspace manifest and target dir in global cache tracker#13846baby230211 wants to merge 2 commits into
Conversation
5f32f71 to
15e2863
Compare
| basic_migration( | ||
| "CREATE TABLE workspace_manifest_index ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| name TEXT UNIQUE NOT NULL, | ||
| timestamp INTEGER NOT NULL | ||
| )", | ||
| ), | ||
| basic_migration( | ||
| "CREATE TABLE target_dir_index ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| name TEXT UNIQUE NOT NULL, | ||
| timestamp INTEGER NOT NULL | ||
| )", | ||
| ), | ||
| basic_migration( | ||
| "CREATE TABLE workspace_src ( | ||
| workspace_id INTEGER NOT NULL, | ||
| target_dir_id INTEGER NOT NULL, | ||
| timestamp INTEGER NOT NULL, | ||
| PRIMARY KEY (workspace_id, target_dir_id), | ||
| FOREIGN KEY (workspace_id) REFERENCES workspace_manifest_index (id) ON DELETE CASCADE, | ||
| FOREIGN KEY (target_dir_id) REFERENCES target_dir_index (id) ON DELETE CASCADE | ||
| )", |
There was a problem hiding this comment.
Whats the motivation for
- Tracking this as 3 separate tables
- Having timestamps for workspace dir, target dir, and workspace dir + target dir
| /// New workspace manifest entries to insert. | ||
| workspace_db_timestamps: HashMap<WorkspaceManifestIndex, Timestamp>, | ||
| /// New target dir entries to insert. | ||
| target_dir_db_timestamps: HashMap<TargetDirIndex, Timestamp>, | ||
| /// New workspace src entries to insert. | ||
| workspace_src_timestamps: HashMap<WorkspaceSrc, Timestamp>, |
There was a problem hiding this comment.
What does db mean in this context?
I think for git
git_dbis the.gitgit_checkoutis a work dir of a shared.git
| pub encoded_workspace_manifest_name: InternedString, | ||
| pub encoded_target_dir_name: InternedString, |
There was a problem hiding this comment.
When the others refer to "encoded" they are referring to how we translate package names to file names.
That doesn't quite make sense here and just naming these target_dir and workspace_manifest_path should work
There was a problem hiding this comment.
i'll rename it with target_dir_path and workspace_manifest_path for these naming.
Thanks.
| /// Indicates the given [`WorkspaceManifest`] has been used right now. | ||
| /// | ||
| /// Also implicitly marks the workspace manifest used, too. | ||
| pub fn mark_workspace_src_used(&mut self, workspace_src: WorkspaceSrc) { |
There was a problem hiding this comment.
Huh, I wonder why we exposed these in the API, rather than taking parameters. Seems like it creates more boilerplate for the callers
| HasDevUnits::No | ||
| } | ||
| }; | ||
| let _ = &gctx.deferred_global_last_use()?.mark_workspace_src_used( |
There was a problem hiding this comment.
If we remove let _ = &, rustc would be warning as follow
rustc: unused borrow that must be used (unused_must_use)
There was a problem hiding this comment.
I removed it locally and didn't get any message...
gctx.deferred_global_last_use()?
.mark_workspace_src_used(global_cache_tracker::WorkspaceSrc {
workspace_manifest_name: InternedString::new(ws.root_manifest().to_str().unwrap()),
target_dir_name: InternedString::new(
ws.target_dir().as_path_unlocked().to_str().unwrap(),
),
});There was a problem hiding this comment.
This is the error msg where runs on CI.
https://github.com/rust-lang/cargo/actions/runs/9055535414/job/24876799051#step:5:687
There was a problem hiding this comment.
That has a leading & that can be removed
There was a problem hiding this comment.
It works. Thanks, I've updated.
| ); | ||
| } | ||
|
|
||
| // Flushes all of the `target_dir_db_timestamps` to the database, |
There was a problem hiding this comment.
Review note: I've not yet dug into all of the DB operations
9f069a9 to
d55dda7
Compare
7d4fbbe to
481de08
Compare
|
☔ The latest upstream changes (presumably #13979) made this pull request unmergeable. Please resolve the merge conflicts. |
|
As this is marked as a draft, @baby230211 what do you see as the next steps before marking this ready for review? |
|
@epage , Sorry for pending this PR so long, the final step here is to record the manifest lock file in manifest table i think. |
|
You're ok. I just wanted to check if there was something waiting on me. |
|
Hello @epage , i would like to re-work on this PR recently. |
|
Lockfile tracking was mostly intended to prep for #13137. We'll likely need to database migrations anyways so probably fine to skip for now so long as we understand how we would support it in the future. |
|
☔ The latest upstream changes (possibly a7cdba1) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
As this has been waiting-on-author for a year, I'm going go ahead and close this. We are very much interested in this moving forward, whether by the original author or someone else. |
What does this PR try to resolve?
Fix #13136
This PR aims to track of the following data in GC for further garbage collection use.
There will be three new table for this features.
How should we test and review this PR?