Skip to content
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

What is the root cause of the performance improvement from 0.19.0 to 0.20.0 #214

Closed
ImJeremyHe opened this issue Sep 12, 2022 · 3 comments
Closed

Comments

@ImJeremyHe
Copy link

ImJeremyHe commented Sep 12, 2022

I mocked 10000 transactions to check the performance for revm. After bumping revm to version 0.20.0, I found there is a great improvement.
I have checked the release log, but still have no clue.
Can anyone help me find out what is the root cause? Thanks!

@rakita
Copy link
Member

rakita commented Sep 12, 2022

Initialization was not optimized earlier and precompile "Loading" was done in the not fastest way, So I optimized that part and it became faster.
This part:

let mut subroutine = SubRoutine::default();
if env.cfg.perf_all_precompiles_have_balance {
// load precompiles without asking db.
let mut precompile_acc = Vec::new();
for (add, _) in precompiles.as_slice() {
precompile_acc.push(*add);
}
subroutine.load_precompiles_default(&precompile_acc);
} else {
let mut precompile_acc = Map::new();
for (add, _) in precompiles.as_slice() {
precompile_acc.insert(*add, db.basic(*add));
}
subroutine.load_precompiles(precompile_acc);
}
was replaced with this
let journaled_state = if GSPEC::enabled(SpecId::SPURIOUS_DRAGON) {
JournaledState::new(precompiles.len())
} else {
JournaledState::new_legacy(precompiles.len())
};

Cached precompile HashMap here gave speed up: https://github.com/bluealloy/revm/commits/main

This is good comparison of simple SM call that does nothing that is x4 faster than 1.8: https://github.com/cl2089/rust-evm-bench

An additional change is related to Bytecode analysis. You can read about it here: #121

@ImJeremyHe
Copy link
Author

Thanks for your reply! I will take a further look for it.

@rakita
Copy link
Member

rakita commented Sep 14, 2022

If you want to see where exactly the processing went I would recommend doing cargo flamegraph and comparing commits from this branch: https://github.com/cl2089/rust-evm-bench it is very visually evident

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants