Skip to content

Optimize the trie prefetcher #31831

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

Open
rjl493456442 opened this issue May 15, 2025 · 5 comments
Open

Optimize the trie prefetcher #31831

rjl493456442 opened this issue May 15, 2025 · 5 comments

Comments

@rjl493456442
Copy link
Member

By revamping the block prefetcher, state retrieval has been significantly optimized.
However, the account trie and storage trie updates is occasional slow.

In Geth’s workflow, state is typically fetched from the flat-state, while dirty states,
such as accounts and storage slots modified during transaction execution, are
scheduled for prefetching from the trie. This is based on the assumption that these
trie nodes are likely to be updated at the end of block execution.

Once all transactions in the block have been processed, Geth flushes all dirty states
into the trie and re-computes the state root. At this point, Geth is blocked until all
pending trie prefetching tasks are completed and then reuse the trie from prefetcher
for state rehasing. Preliminary investigation shows that a significant portion of the
time spent on storage updates is actually due to waiting on the trie prefetcher,
which appears to be inefficient.

An additional observation is that storage modifications are highly uneven. Some
contracts may modify hundreds of storage slots within a single transaction, creating
huge workload imbalances for the trie prefetcher.

@nadtech-hub
Copy link

May I take on it?

@will-2012
Copy link

@rjl493456442
Copy link
Member Author

@will-2012
Copy link

will-2012 commented May 16, 2025

@will-2012 It's blocked here.

https://github.com/ethereum/go-ethereum/blob/master/core/state/state_object.go#L296

Got it, is the inner getPrefetchedTrie waiting for the prefetcher to finish?

@rjl493456442
Copy link
Member Author

yes

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

No branches or pull requests

3 participants