-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Faster mapping execution #856
Comments
I assume this issue is about improving indexing time. First we shoud try to answer questions such as:
Case studiesI went ahead and did three case studies: Compound, ENS and Uniswap. One case I didn't cover is IPFS, which none of these use. Compound makes 3-4 contract calls per event. The time to make a contract call is dependent on the latency to the eth node, so I can't measure on my machine, we'd need production timings, but I'd suspect that the contract calls dominate the indexing time. ENS does no contract or ipfs calls and has very simple mappings. From a cold db, fetching blocks from the eth node dominates the indexing time. From a warm DB, it gets more subtle. The three major steps to process a block (and my local measurments for ENS) are:
Steps 1 and 3 take a while because they involve the DB, while step 2 is the interaction with wasm. Uniswap like ENS doesn't do contract or ipfs calls. However it has more complex mappings that take ~15ms per event, making the runtime the slowest step in many blocks. Possible solutionsFrom a cold db I don't have a better idea other than making sure there's good networking to the eth node, and then there are also bigger ideas such as local contract execution. From a warm DB there are a few things: For Compound, caching contract calls might help. Or running nodes in the local cluster to reduce latency. For ENS step 3 is significant, applying the operations to the DB seems to be a bottleneck if the mapping is simple and each block has only a few events. We could pipeline operations to the DB so that we could start processing the next block while the previous one is being applied. This would require architectural changes, currently the block stream cannot proceed while the previous block has not been fully processed. Could be an up to 2x speed up for some blocks. For Uniswap, Step 2, the runtime, becomes the bottleneck. I see two things that we can improve: First being smarter with allocations and pre-allocating memory when passing objects to AS. I believe this would give a 2x speed up. Then there is swapping out wasmi for something more performant, Cranelift + wasmtime or wasmer. This is more work but should give at least a 10x speed up to the runtime. |
As a part of this, I've been observing the timings of the Decentraland subgraph in production. Observations:
|
Looking at logs in the hosted service, DB contention doesn't look like a big issue, so I don't have new or confirmed ideas for why On general event processing time, thread pool contention is clearly being a factor, #926 will give clear confirmation of this. My plan there would be:
We should do 1 now, and if it works leave 2-3 in the technical debt bucket. |
Old, also we switched to wasmtime. |
No description provided.
The text was updated successfully, but these errors were encountered: