Conversation
MichaelEischer
left a comment
There was a problem hiding this comment.
My impression that this PR merely shift the complexity from one place to another: now there's a Backend and a CachedBackend which requires using the right one to get tree packs cached.
I'd also like to keep the explicit tracking of tree packs. My suggestion would be to replace the PerformReadahead closure with a method to register Handles which should be cached. This would also fit in nicely with the other already existing methods for cache management.
|
Thank you guys for your feedback! I agree that the new My main intention in this was to change how restic determines which files are to be cached. The Also I find it way more natural to determine by its attributes whether a file is to be cached and not by saving its name somewhere. For all files except pack files this is the way the cache already works (just determining by the filetype wheter the file is to be cached). So I would say it is much more natural to extend this to all files - and this requires for pack files to give the cache not only the information about the filetype, but also about the blobtype. So I propose to extend the function signatures in the |
9fe25f8 to
41c1a78
Compare
|
I changed the logic (and the description of this PR). Now the |
41c1a78 to
f4426c3
Compare
MichaelEischer
left a comment
There was a problem hiding this comment.
I like the idea of annotating which type of blobs in contained in a pack file in general. However, we could (accidentally) end up with a few places in the code which no longer cache a file, as the burden to determine the file type now has moved to the caller and out of the cache backend. On the other hand it should be easier for the caller to know whether a file will be cached or not.
I've found a few more places in the code whose behavior is affected by the cache changes:
CreateIndexFromPacksininternal/repository/repositorycallsPackListwhich then has to read a pack file from the repository. In most cases there pack file is probably not yet part of the repository index and thus this shouldn't make much of a difference.pack.Listis called inpacksToBlobsofcmd_find. This would no longer cache the pack file if it is a tree pack. Although, I'd expect that only a very small number of packs will be used (actually just one before #3427)cat pack ...incmd_catwould no longer cache a tree pack when dumping its content. But I guess that's not much of a problem.printPacksincmd_debugusespack.Listwhich would no longer be cached. But I guess that would be ok for a debug command.- And finally
examinePackincmd_debugusesLoadAllandbe.Loadwhich would no longer cache an examined tree pack. But I think the same reasoning as with the previous debug command applies.
So in summary I think these small behavior changes should nevertheless be ok. I only have one nitpick left before we could merge this, see the comment below.
f4426c3 to
81876d5
Compare
|
@MichaelEischer Thanks a lot for your review and big excuse for the very late reply. I was heavily busy with finding a new home for my family and finally relocating. And wow, that was really a very busy time... I also rebased this PR to solve the merge conflicts. Hope it is now in a good shape to be merged. |
MichaelEischer
left a comment
There was a problem hiding this comment.
LGTM.
@MichaelEischer Thanks a lot for your review and big excuse for the very late reply. I was heavily busy with finding a new home for my family and finally relocating. And wow, that was really a very busy time...
While not completely finished I'm starting to see light at the end of the tunnel now ;-)
No problem. That really sounds like a lot of work, and I guess it's always surprising how much stuff accumulates over the years.
What does this PR change? What problem does it solve?
Simplifies the cache logic:
This closure is used for one single purpose: If a pack file is loaded and not yet contained in the cache, it will be loaded and saved in the cache for future use.
packer_manager.I changed the logic and added
BlobTypeto the handle used to access the backend. This is in fact only used by the cache to determine whether a pack file from the backend should be cached.As a side effect no tree packs need to be determined and stored within the index implementation, but instead mixed packs are saved.
Note that this PR does change the behavior of restic with respect to these points:
pack.Listwhich is used in some places.Was the change discussed in an issue or in the forum before?
No.
Checklist
changelog/unreleased/that describes the changes for our users (template here)gofmton the code in all commits