-
Notifications
You must be signed in to change notification settings - Fork 809
feat(Jurnal): Accounts saved in index map. #2878
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
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #2878 will degrade performances by 7.38%Comparing Summary
Benchmarks breakdown
|
fn sload( | ||
&mut self, | ||
address: Address, | ||
address_or_id: AddressOrId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface got changed so it now can process both account id or address.
Account id is obtained on loading of the account and it can be used to fetch the account faster from journal.
} | ||
|
||
/// Warms the coinbase account. | ||
fn warm_coinbase_account(&mut self, address: Address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can load coinbase from the start and make it warm (if needed), as fetching it in post execution state is going to be fast with account id.
fn get_account(&mut self, account_id: AccountId) -> (&Account, AddressAndId); | ||
|
||
/// Sets the caller id. | ||
fn set_caller_address_id(&mut self, id: AddressAndId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caller/coinbase/txtarget addresses and ids are saved in Journal so they can be fetched on demand.
) -> Vec<(Address, TransitionAccount)> { | ||
let mut transitions = Vec::with_capacity(evm_state.len()); | ||
for (address, account) in evm_state { | ||
for (account, address) in evm_state.take_accounts().into_iter().flatten() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterating over accounts
let auth_acc = state.get(&signer.address()).unwrap(); | ||
assert_eq!(auth_acc.info.code, Some(Bytecode::new_eip7702(FFADDRESS))); | ||
assert_eq!(auth_acc.info.nonce, 1); | ||
println!("state: {:#?}", state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
println!("state: {:#?}", state); |
Journal function now contain
AddressOrId
field that allow fetching account by or or by addressOutput state is now a index map, that contains pages of accounts and hashmap that maps address to the index.
Analysis:
codspeed times are very slower than running on machine but even with them we can see order of magnitude difference between transfer and CALLs. 1000tx transfers with commit take 2.8ms that means one transfer is 2.8us and degradation is 0.2us per transaction, while 50 CALLs are 97us and it is improved to 91 µs
And when i run this on machine,
revme bench transfer-multi
I gettransact_commit_1000txs
time:[387.81 µs 393.68 µs 398.68 µs]
which means on the real machine it is 0.4us per transaction and diff is 0.05us or 50ns .For context 50ns degradation for 3 billion transactions (number of mainnet transactions) are few (two/three) minutes of difference.
My conclusion is even if transact_commit_1000tx is worse by 7%, an improvement of 7% for CALL or %5 SSTORE is worth a lot more.