-
Notifications
You must be signed in to change notification settings - Fork 619
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
BTreeMap feature flag for zk-EVMs #2048
Comments
Interesting, did you try different Hashers for HashMap? This can be enabled with alloy features (not sure when it is added, maybe it is not inside v45). I woundn't mind adding feature flag for btreemap switch it is small diff but it is a small change |
Just realized there is more HashMap's to replace with BTreeMap's. Going to compare cycle counts again. Looks like a seperate zkvm feature is the way to go. Also the feature can go directly to |
This brings the total reduction to %3.4. I still want to benchmark |
Gotcha, woudn't mind if you made a pr. But be aware if reth crates are used, they probably use alloy hashmap not one from revm. |
Yeah that might be problematic. We'll see 👍 |
From RiscZero's docs.
In ZkVm's BTreeMap's are preferred over HashMap's due to their better performance in guest codes.
A lot of projects that need ZK-proving EVM or even Ethereum blocks choose rust-based ZkEVM's for their developer friendly and efficient workflows. And most of these projects end up leveraging this repository.
On our tests for Citrea, we've found out a cycle count (less cycle counts -> cheaper, faster proofs) improvement of 3% can be achieved if the state related structs are modified to use
BTreeMap
instead ofHashMap
. The patch we used for this benchmark forrevm
be found here. The changes are based on v45 as Citrea currently depends on v45.The proposed change is to create a feature flag that swaps out HashMaps for BTreeMap wherever it is applicable, so that zk-EVM projects gets above mentioned benefits.
If accepted, I would like to start working on this right away.
Also, just to mention I've ran the benches on v45, and BTreeMap patch beats the original HashMap version:
Again, if not opposed I can run benches on the latest code to see if BTreeMap's still performing better, if so, we can forget about feature-gating and just use BTreeMaps.
The text was updated successfully, but these errors were encountered: