Skip to content

Conversation

@figtracer
Copy link
Contributor

according to benchmarks, this increasingly improves perf if accounts accessed >20, below this value a sequential approach is more beneficial due to overhead

@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Dec 24, 2025
@figtracer figtracer closed this Dec 25, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in Reth Tracker Dec 25, 2025
@mattsse mattsse reopened this Dec 25, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Reth Tracker Dec 25, 2025
@gakonst
Copy link
Member

gakonst commented Dec 25, 2025

Nice - what's the impact of this overall?

@figtracer
Copy link
Contributor Author

the function is called by the payload processor MultiProofTask::on_state_update() when we have state changes

i got these results when benchmarking on my machine

Accounts Accessed ~Before (µs) ~After (µs) ~Speedup
10 31 38 0.82x
20 61 51 1.2x
50 289 125 2.3x
100 571 214 2.7x
200 1,200 387 3.1x
300 1,810 560 3.2x

i think there's another PR working on this as well #20475

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this makes a lot of sense

we can even simplify the collect impl with #20653

Comment on lines 238 to 244
.collect();

let mut hashed_state = HashedPostState::with_capacity(hashed.len());
for (hashed_address, info, hashed_storage) in hashed {
hashed_state.accounts.insert(hashed_address, info);
if let Some(storage) = hashed_storage {
hashed_state.storages.insert(hashed_address, storage);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this we can simplify with

#20653

after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on it

@mattsse mattsse marked this pull request as ready for review December 28, 2025 10:17
@figtracer figtracer force-pushed the parallelize_evm_state_to_hashed branch from 34bf944 to f489c99 Compare December 28, 2025 12:45
@figtracer
Copy link
Contributor Author

there's potentially another optimization, similar to this one, here:

fn multiproof_targets_from_state(state: EvmState) -> (MultiProofTargets, usize) {
let mut targets = MultiProofTargets::with_capacity(state.len());
let mut storage_targets = 0;
for (addr, account) in state {
// if the account was not touched, or if the account was selfdestructed, do not
// fetch proofs for it
//
// Since selfdestruct can only happen in the same transaction, we can skip
// prefetching proofs for selfdestructed accounts
//
// See: https://eips.ethereum.org/EIPS/eip-6780
if !account.is_touched() || account.is_selfdestructed() {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants