Open EmiM opened 3 years ago
Let's say we're going to spend a full day on this and then discuss before we do more.
Also, to add a bit more clarity, I think these are the things we're seeing here that we don't understand.
One theory we have is that the kinds of connections we need to make to sync old entries are simply failing at the network layer.
(@EmiM, @kowalski please correct me if any of this is wrong, as this is from memory from our calls.)
Which kind of db is this?
I believe it’s an EventStore.
On May 9, 2021, at 2:56 PM, Mark Robert Henderson @.***> wrote:
Which kind of db is this?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ZbayApp/zbay/issues/776#issuecomment-835863614, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABUFLQXADFIUYK4DNTRCJ3TM3LF5ANCNFSM43OLTDGA.
EventStore definitely shouldn't take that long to load. To be clear, this is NOT replicating from the network but simply loading from IPFS into memory? Is it an in-process IPFS node or is it using an HTTP API?
@aphelionz yes, thats right, it looks like it takes a lot time to read data that is stored locally. We're using js-ipfs, so inprocess node.
@kowalski thanks - if I check out this code and run it locally, can I easily replicate this state?
While I was preparing docker image with very basic setup I noticed that the long load() time is probably our fault. Normally we run it (waggle) inside electron main process and then loading takes at least 13 seconds for largest eventstore (about 1000 records). By running it outside electron (as it is e.g in prepared image) time is shortened to 1.5 second.
Very interesting. What is the reason for electron slowing it down? Something due to leveldb, maybe?
I don't know the exact reason. Orbitdb performs many operations, perhaps electron slows it down because of single threading and electron cutting between orbitdb operations?
For test I spawned a process with waggle (from electron main process) and messages also loaded very fast. https://www.electronjs.org/docs/tutorial/performance#how-2 I think that if we'd use worker threads or something like that, the problem will be solved.
Note for myself: https://news.ycombinator.com/item?id=27156872
Here's an attempt at an isomorphic OrbitDB worker that uses web workers int he browser and worker threads in node.js: https://github.com/tallylab/orbitdb-worker
It might need to be updated but hopefully it provides a good start.
@vinkabuki assigning this to you since you're working on this now, right?
We've fixed this, right? @vinkabuki
@EmiM @vinkabuki is this still happening?
Orbitdb entries need to be loaded to memory in order for us to make queries. Even though our databases are small (up to 500 entries) loading them can take up to a minute. I posted a question in gitter: https://gitter.im/orbitdb/Lobby?at=608180542e5574669b51a8c2 They have plans for making it more efficient: https://github.com/orbitdb/orbit-db/issues/819
I think the next step is to find out what exactly in db.load() is so slow and maybe find out if we can do anything about it.