-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
don't cache entire mfs tree on add finalize #3027
Conversation
License: MIT Signed-off-by: Jeromy <[email protected]>
LGTMed in person. |
@Stebalien (or anyone with background on this PR) Could you expand on why there was a memory bloat in (Related to ipfs/go-mfs#36.) |
MFS caches directory entries on access. Without |
Thanks! I wasn't aware of that (another thing that should be documented about the cache mechanics - ipfs/go-mfs#37). Then we should provide a |
Ideally, we'd clear the cache when it reaches some size. I'm not sure about adding another method, that feels like pushing a concern to the user that they shouldn't have to think about (better than Although, for this case, an option when constructing the MFS instance would also suffice (for now). |
Yes, that's why I suggested (but not very clearly, sorry) just to provide a method like I think I need to give the current cache some more thought, we are using it for (maybe too) many things, ideally I want a cache with dirty states that when I flush/sync the directory i's wiped out (something that I think we're not doing at the moment), and separately a read cache with a maximum capacity of N and a LRU system. That second cache doesn't need to be cleaned up, just assigned a maximum size to keep memory use in line. |
It makes sense to have a method that returns both the names and the entries atomically. However, as a user, I'd expect that to cache the same way
Thinking about this a bit, the "cache" isn't really a cache; it's a list of open files. If we clear it, we invalidate any open directories. I think we might need to (a) track open files/directories separately from the "cache" and (b) add a If we do that, we'll probably want some kind of |
Sorry I'm lost, what atomicity are referring to?
Why opened? I think it's any entry we access when retrieving a child or adding one.
Why? If the information there is saved in the lower UnixFS layer when doing something like
I meant to use which attempts to list everything not just opened file objects. (So basically at this point I'm pretty sure that I missed some important point in the conversation, my confusion is mostly related to the shift from avoiding |
(this was a technically correct unnecessary detail, you can ignore it) I'd expect
Because of how we lock files open for reading/writing. If we open a file for writing, clear the "cache", and then try to reopen the file for writing, it'll work because we'll be using a different FSNode. |
Yes, exactly, providing a |
This should prevent memory bloat during the finalize call of add
License: MIT
Signed-off-by: Jeromy [email protected]