-
Notifications
You must be signed in to change notification settings - Fork 2.6k
try-runtime-cli: Lazy Download #13562
Comments
related: chopsticks storage layer https://github.com/AcalaNetwork/chopsticks/blob/master/packages/chopsticks/src/blockchain/storage-layer.ts |
I tried out this subway to see if it could handle the batch request that you are currently fixing in one MR. |
This could be useful - but worth keeping in mind that (unless using a remote node) the biggest bottleneck is merkelizing the keys when loading them in TextExternalities, rather than fetching them from the node |
Yes there could also be a much more optimized way for this; like having an export-state RPC or something that encodes and sends the whole Trie. But yea, the lazy approach should also help a lot. |
Also, I think Centrifuge's fudge might have the right inspirational piece of code that lets you have |
batch request is not yet implemented but it is trivial to support it |
This is state sync. This downloads the entire trie at a given block. It is used by warp sync.
What you mean by backed by a database path? |
Thanks @bkchr this sounds very worth looking into. Perhaps not for lazy download but for saving entire state to disk that can quickly be loaded up again on subsequent runs (existing snapshots created by 'create-snapshot' still take 300+ seconds on my M2 Max Macbook Pro to load, bc building the tri is so expensive). I've been meaning to create an issue to improve the performance of 'snapshot' mode, will mention this as an option to consider. |
why does it need to build trie? there is (almost) no such logic in chopsticks |
This is a good question. The trie may even be disadvantageous it'll slow things down a lot and it's unlikely that there'll be many keys needed cached in-memory at any one time. I'll start hacking on a simple storage layer that accesses storage from a node and stashes results in a flat in-memory LRU cache. No trie, just flat key-value. If this works I'll try different workloads on it and see how it performs both in terms of memory and speed. |
You can just use the |
If I'm reading the code correctly, this could be because key-values are inserted in the trie one at a time here:
If you pass multiple/all values at once, it should be much faster because the trie root would not need to be recalculated after each insertion. |
I assumed they were being inserted one at a time for a reason. I'll try batch inserting, if it works it'll speed things up dramatically, thanks for the advice. edit: this had a big impact, PR with before/after performance benchmarks: #14004 |
Ideally, we want the If we remove this assumption, a whole lot of things will be easier, and as @liamaharon pointed in a comment, a flat
Not just for caching, but also as the first point of response. The scenario I have in mind is that you run |
That isn't required, you can just take all the key/value pairs and calculate the storage root :P No problem.
This is basically an enhanced |
fwiw, ➕ for this approach. In the case of data gathering for analysis and block replays with different state for testing purposes this would be very useful. |
@gpestana are there cases where reading from a DB path would be helpful in ways that reading from a snapshot would not? Snapshots can be created from arbitrary block numbers and (shortly) will be able to be loaded almost instantly. Update on this: I've had success writing directly to the ext |
FYI, I have created a dedicated issue to track the progress of allowing db-backed externalities to be used with the try-runtime-cli. Let's maintain the focus of this issue on lazy-download. Upon introducing a DB path option, I think lazy-download is likely to be a preferred mode only when using a remote node and the state cannot fit in memory.
Although we should definitely eventually implement lazy-download, I wanted to note that it may not be as high priority as some other try-runtime-cli tasks, because most bases will be covered and I'm uncertain how prevalent use case of using it with a large remote node will be. |
Hi, I'm curious if there is currently some progress on it |
I think its still a high value issue - just currently resource starved. We instead prioritized the versioned runtime upgrades to reduce the number of error sources when migrating. |
Yeah I've made decent progress with this and have a working PoC, I am planing to pick it up again once the higher prio runtime upgrade stuff is shipped. @crystalin fyi I have actually run the PoC with moonbeam state and runtime testing a runtime migration and it executed in just a few seconds :) |
That's awesome. |
Hey @crystalin, we've decided to deprioritise this for now to focus on some higher priority features. I have a PoC branch here you're welcome to pick up if you need the feature. |
Moved: paritytech/try-runtime-cli#8 |
see: #13109
The text was updated successfully, but these errors were encountered: