Cache hash computations for repro#10927
Conversation
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10927 +/- ##
==========================================
+ Coverage 90.68% 91.01% +0.33%
==========================================
Files 504 505 +1
Lines 39795 41027 +1232
Branches 3141 3248 +107
==========================================
+ Hits 36087 37340 +1253
- Misses 3042 3047 +5
+ Partials 666 640 -26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
What are you trying to optimize for? Are you trying to reduce multiple If former, I think we should reorganize/rearchitect so that we don't make duplicated calls, avoiding the need for caching. If you are optimizing for the whole session, it may not be safe because it could have been modified, maybe by the user, or a different dvc process executing separately. DVC does not re-hash files, so successive If you can share the perf numbers (before and after), then that would be great. But I'd avoid adding caching as much as possible. |
The latter. Looking into it more now, I think you're right with all of your criticisms, it seems like I was a bit too zoomed-in to see the bigger picture 😅 We could technically change the architecture here to store the cache across repo resets, but I agree with you that this isn't worth the added complexity (now that I know DVC doesn't re-hash files) since it's just for |
|
The hashes are saved into a sqlite database, which is used more like a key-value store. Some additional references where we get values from db and where we save them back: |
|
Thanks for the explanation and links to the codebase. Yeah, in this case I don't think the sort of caching this PR adds is of any use, so I'll close it now. |
This adds a
_hash_cacheto repos to store computed hashes and metadata in memory when a command is run. This way, the hash does not need to be recomputed in every step and_buildcan be skipped (at least for dependencies, outputs obviously need to update the cache).It also adds some tests for the basic cases (hash can be used, hash must be overwritten, and hash must be reset when repo is reset).