Skip to content
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

Tensor/group deletion perf fix + corruption proofing #1404

Merged
merged 10 commits into from
Dec 22, 2021

Conversation

farizrahman4u
Copy link
Contributor

🚀 🚀 Pull Request

Checklist:

  • My code follows the style guidelines of this project and the Contributing document
  • I have commented my code, particularly in hard-to-understand areas
  • I have kept the coverage-rate up
  • I have performed a self-review of my own code and resolved any problems
  • I have checked to ensure there aren't any other open Pull Requests for the same change
  • I have described and made corresponding changes to the relevant documentation
  • New and existing unit tests pass locally with my changes

Changes

  • Avoid flushing for each chunk deletion.
  • Delete meta before chunks, so worst case scenario is unaccounted chunks instead of corrupt dataset.

@CLAassistant
Copy link

CLAassistant commented Dec 21, 2021

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Dec 21, 2021

Codecov Report

Merging #1404 (1579d19) into main (e42abd2) will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1404      +/-   ##
==========================================
- Coverage   92.28%   92.20%   -0.08%     
==========================================
  Files         175      175              
  Lines       13826    13825       -1     
==========================================
- Hits        12759    12748      -11     
- Misses       1067     1077      +10     
Flag Coverage Δ
unittests 92.20% <100.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
hub/core/dataset/dataset.py 93.18% <100.00%> (-0.36%) ⬇️
hub/core/lock.py 77.04% <0.00%> (-6.56%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e42abd2...1579d19. Read the comment docs.

jraman
jraman previously requested changes Dec 21, 2021
Copy link
Contributor

@jraman jraman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Jira ticket to this PR.

Add followup Jira to garbage collect dangling chunks.

@@ -369,16 +369,20 @@ def delete_tensor(self, name: str, large_ok: bool = False):
)
return

delete_tensor(name, self.storage, self.version_state)
initial_autoflush = self.storage.autoflush
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to put this in a try-finally with self.storage.autoflush reset in the finally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do that in other places too. Should be changed everywhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed everywhere.

tensors = [
posixpath.join(name, tensor) for tensor in self[name]._all_tensors_filtered
]

meta.groups = list(filter(lambda g: not g.startswith(name), meta.groups))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor!

@@ -420,30 +424,22 @@ def delete_group(self, name: str, large_ok: bool = False):
)
return

initial_autoflush = self.storage.autoflush
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment re: resetting self.storage.autoflush

@farizrahman4u farizrahman4u dismissed jraman’s stale review December 22, 2021 05:32

Requested changes made.

@farizrahman4u farizrahman4u merged commit 977e25a into main Dec 22, 2021
@farizrahman4u farizrahman4u deleted the fr_fast_del_tensor branch December 22, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants