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

core: implement in-block prefetcher #31557

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Apr 4, 2025

This pull request enhances the block prefetcher by executing transactions in parallel
to warm the cache alongside the main block processor.

Unlike the original prefetcher, which only executes the next block and is limited to chain
syncing, the new implementation can be applied to any block. This makes it useful not
only during chain sync but also for regular block insertion after the initial sync.

TODO

  • experiment whether the state hashing is necessary in block prefetcher (duplicate with trie prefetcher)

@rjl493456442 rjl493456442 requested a review from holiman as a code owner April 4, 2025 05:21
@rjl493456442
Copy link
Member Author

PR: bench05
Master: bench06

  • PR is about 10% faster than Master
  • The speedup comes from the faster account/storage read
  • The memory allocation and CPU usage is about 2x than master
截屏2025-04-04 13 22 31 截屏2025-04-04 13 25 25 截屏2025-04-04 13 25 45 截屏2025-04-04 13 28 30 截屏2025-04-04 13 29 13 截屏2025-04-04 13 29 51
File: geth
Type: inuse_space
Time: 2025-03-31 19:57:06 CST
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) alloc_space
(pprof) top
Showing nodes accounting for 3139.56GB, 49.79% of 6305.50GB total
Dropped 2237 nodes (cum <= 31.53GB)
Showing top 10 nodes out of 245
      flat  flat%   sum%        cum   cum%
  886.65GB 14.06% 14.06%  1019.34GB 16.17%  github.com/ethereum/go-ethereum/trie.(*hasher).hashFullNodeChildren
  472.06GB  7.49% 21.55%   935.83GB 14.84%  github.com/ethereum/go-ethereum/trie.decodeFull
  463.89GB  7.36% 28.90%   463.89GB  7.36%  github.com/ethereum/go-ethereum/trie.decodeRef
     320GB  5.07% 33.98%      320GB  5.07%  github.com/ethereum/go-ethereum/core/vm.(*Memory).Resize
  298.84GB  4.74% 38.72%   298.84GB  4.74%  github.com/ethereum/go-ethereum/rlp.(*encBuffer).makeBytes
  227.90GB  3.61% 42.33%   227.90GB  3.61%  github.com/ethereum/go-ethereum/trie.(*tracer).onRead
  147.57GB  2.34% 44.67%   147.57GB  2.34%  github.com/ethereum/go-ethereum/common.RightPadBytes
  109.50GB  1.74% 46.41%   110.78GB  1.76%  github.com/ethereum/go-ethereum/rlp.(*encBuffer).writeBytes
  106.61GB  1.69% 48.10%   106.61GB  1.69%  golang.org/x/crypto/sha3.NewLegacyKeccak256
  106.55GB  1.69% 49.79%   106.55GB  1.69%  github.com/ethereum/go-ethereum/core/vm.codeBitmap

The main memory allocator is trie loader and trie hasher

@rjl493456442 rjl493456442 force-pushed the in-block-cachewarmmer branch from c8939b0 to f4f1f5a Compare April 6, 2025 07:20
@rjl493456442 rjl493456442 force-pushed the in-block-cachewarmmer branch from f4f1f5a to ce318a3 Compare April 6, 2025 11:55
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

Successfully merging this pull request may close these issues.

1 participant