-
Notifications
You must be signed in to change notification settings - Fork 54
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
Replace ds.MapDatastore with proper in memory datastore #40
Comments
Blocked by #44 |
I have a few questions on this:
|
Would also be super handy to have some performance tests before pushing forward with this. Marking as blocked by #30 |
I agree its going to be important to track the perf of the implementation, but I wouldn't call it a full blocker of this feature. The great thing about our datastore interface is the freedom to use whichever engine we need with no code change. So we can develop the in-memory versions without changing any structures. So as long we are building the in-mem engine using decent patterns, it's always going to be faster than the disk-backed persistence storage via BadgerDB. |
I think starting off using an existing BTree implementation should get as far enough for now. BuntDB is honestly a fairly good starting point as well, which is a full-featured storage engine already build on their BTree implementation. |
The other design goal is Transaction support, if we do things ourselves we have to implement them from scratch. BuntDB already supports Transactions |
Been having quite a long think about this: RE: custom vs super generic/existing solution: Pros (for custom):
Cons:
RE: Which existing package to use:
Also - semi-related, I think we can probably restructure the code in db.go to break the code-dependency on any given implementation - moving the badger code out to a new package, and likewise for the IM stuff. I might do this first (#50). Your thoughts? |
Love the input! Even with these pros/cons for custom, im still leaning towards generic implementation, such that we can still wrap the given storage with the Additionally, some of the various deployment targets will certainly need their own specific datastore implementations. Like compiling the DB via WASM to run in a browser, will need to have an adapted As for BadgerDB, I don't see where you can run it as "in-memory" mode, without just using some various shortcuts/hacks w.r.t the Sync/Merge/Flush options, and a virtual memory backed filesystem. Unless im missing something here :/ As for BuntDB, not sure how I missed the single write transaction limitation..certainly a blocker. I'm more than happy for us to dedicate whatever time is necessary, and even a long-term maintenance window is fine. |
Ah was for sure going to keep the ipfs interfaces and all the Wrap stuff with a custom implementation - would be a big loss losing that even if the alternative means a bit of wasted CPU/in-store-code-complication. According to the docs BadgerDB has an IM flag here: https://dgraph.io/docs/badger/get-started/#in-memory-mode-diskless-mode - I think it must be in v2 or higher as the current version we use doesn't seem to have it. (we are on v1, there is a v3 now). There is a file-format change between v1 and v2 though, so you/product would need to give the green light, as any early users could be affected by that. We could try and use two different (major) versions of the package as it looks like Go supports that, but maybe that could cause confusion and it would be better to find another package in the short-term (I assume we'll update badger at somepoint anyway?). Will have a look for others in a bit. |
Thats weird, I went looking for a in-memory mode for Badger, but couldnt for the life of me find one lol. Let me double check how its implemented internally, but other than it looks like a good (at least short term) solution. As for the required upgrade, thats fine at the moment as a breaking change. Rather upgrade now and not have to do it later as more partners start building more involved applications. |
See #52 |
fixed in #56 |
Currently, we use the
github.com/ipfs/go-datastore
implementationMapDatastore
which is basically just amap[string]interface{}
wrapped in theDatastore
interface as our default "in-memory" datastore.The main problem with this is a lack of in-order iterator and prefix queries. Go's maps don't have a predefined order, and using a
range
over the key-value pairs has an undefined order.Our query system is designed on the assumption that our underlying storage engine supports efficient in-order range/prefix scans over a collection of key-pairs.
A few options are available here:
Datastore
interface wrapper around an existing in-memory go storage engineThe text was updated successfully, but these errors were encountered: