-
-
Notifications
You must be signed in to change notification settings - Fork 55
Reduce memory footprint of a log instance & improve load time for orbit-db stores #136
Comments
@mistakia thank you for opening this discussion! This is indeed something we should look at and see how we can improve the current implementation. Great thinking here @mistakia as to how to approach improving it! 👍More than happy to help if you want to work on this, and it is much appreciated! ❤️ I'll try to provide some insight, so couple of things worth to emphasize before starting work on this:
I would also recommend to look (and base the implementation on) https://github.com/orbitdb/ipfs-log/blob/local/refs-tests/src/log.js (note the branch) as this branch and code contains upcoming changes to the way the log is loaded, improving performance quite a bit. And I think you'll find the Hope this helps to get started! Also, thank you for all the PRs and work you're doing! I'm slowly going through all of them, bear with me. |
nice work on that branch - loading is indeed MUCH faster. 💪💨 Also, I'm now considering whether it might be better to implement these changes inside an OrbitDB store, where a store keeps a "light" oplog in memory containing just the entry hashes (head + nexts). Changes may still be needed to What would be the current behavior with OrbitDB stores if you don't call |
From what I gathered, it appears that the Store will |
Currently, when a log is loaded, all the data is kept in memory on
log._entryIndex
. Also, constructing a log requires passing in all the entries, which in the case of OrbitDB Stores that means reading all the data from disk (or just the N latest entries).This is not very ideal as the load operation is O(n) and the memory footprint is an issue in mobile environments.
What are your thoughts on making the following changes:
Entries
and/orHeads
with anextsIndex
(aka a entryHashIndex)The following methods would also change:
log.values
would read from disk whenentryIndex
does not existlog.get(hash)
would read from disk whenentryIndex
does not exitlog.has(hash)
would usenextsIndex
whenentryIndex
does not existlog.toJSON
/log.toSnapshot
would includenextsIndex
The following methods would be added:
log.audit
(or similar) to go through and rebuild/validate thenextsIndex
This would allow using just a cache of the
head
and anextsIndex
to create a functional instance ofLog
. Also, using thenextsIndex
one could navigate and load any portion of the log.Happy to take this on and explore better ways to accomplish this but would like some feedback to make sure I'm not missing anything obvious.
The text was updated successfully, but these errors were encountered: