-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Avoid constant rehashing #2988
Comments
We could probably introduce a |
Yes! Although it feels a bit clunky and maybe we can come up with something less invasive public API wise? Here is my uneducated brain dump of ideas: First, just track the changes happened to Second is not an idea, but observation: trie already does hashing for storing leaves. Can we actually fetch the hash of the leaf by its key? I am not sure how the state caching works, but maybe the actual trie access would be elided? There is also a crazy idea that I dismissed almost immediately but then I thought maybe it still has a chance: Maybe instead of hash we could compare the byte blobs directly.
Sounds like a poor man caching, but if we had a ready made tools for that (i.e. patricia tree), this might be the low hanging fruit. |
Looking at the code, it seems that |
@pepyakin The Equality checking on the runtime binary itself is about 0.1-0.12 ms faster by my measurements. The easiest thing to do would be to make the runtime blob (a |
There should be no code re-hashing if the code did not change in a recent blocks. The database supports retrieving value hashes and the executor checks if the hash has changed before querying the full code from the database. |
@pepyakin This implementation should not do any code hashing: substrate/core/state-machine/src/ext.rs Line 194 in aa8c06a
What exactly did you profile? |
I was profiling
I can see that the execution spends 4.21s in |
Just checked the So I guess this has something to do with |
Profiling shows that the most heavy entry in typical execution of factory with wasm-only is constant rehashing of the
:code
storage value:substrate/core/executor/src/native_executor.rs
Line 56 in e63598b
The text was updated successfully, but these errors were encountered: