-
Notifications
You must be signed in to change notification settings - Fork 23
gc: Pass list of paths to fs.remove.
#244
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
Conversation
| return _hash.endswith(HASH_DIR_SUFFIX) | ||
|
|
||
| removed = False | ||
| # hashes must be sorted to ensure we always remove .dir files first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just doubt I have, why .dir files have to be removed first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We consider .dir files (and tracked objects inside) to be one single unit. We use this for optimization (assumptions such as if .dir file exists in the remote, all the directory contents also exist, etc).
We also try to upload all directory contents, and then only if they succeed, we upload .dir files.
So ideally here, we should try to delete .dir file first, and then all of it's contents in bulk and so on for all objects. Then again do bulk for HashFile objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ideally here, we should try to delete .dir file first, and then all of it's contents in bulk and so on for all objects. Then again do bulk for HashFile objects.
Should we open a separate issue for that?
This P.R. just keeps the previous behavior but benefits from filesystems that implement bulk delete like gcfs and s3fs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daavoo You probably don't want to remove that comment completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be better a # TODO: comment to implement what @skshetry described above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daavoo, let's just leave it out. It's harder to associate later in practice (Eg: what if there are overlaps between different .dir files, etc.).
It is unsafe, but gc always is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as we remove .dir files before all other files first then gc should be safe. The optimization isn't affected by overlaps between dirs. The only thing we assume when checking remote status is that if a .dir file exists on the remote, then all files inside that .dir exist. It's more unsafe for us to actually attempt to remove .dir+directory contents, then another .dir+directory contents, and so on, because then we do have to get into figuring out directory overlaps.
The existing behavior (and the current state of the PR) should be fine for now.
4e2864f to
3f563e9
Compare
Codecov ReportBase: 56.87% // Head: 56.78% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #244 +/- ##
==========================================
- Coverage 56.87% 56.78% -0.10%
==========================================
Files 50 50
Lines 3082 3087 +5
Branches 536 538 +2
==========================================
Hits 1753 1753
- Misses 1243 1248 +5
Partials 86 86
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Use "bulk" remove in filesystems that support it.
08fd107 to
daf458f
Compare
Use "bulk" remove in filesystems that support it.
Requires treeverse/dvc-objects#176 to don't break in localfs
Closes treeverse/dvc#5961