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

trie: parallel insert trie when root node is a full node #597

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

Conversation

minh-bq
Copy link
Contributor

@minh-bq minh-bq commented Oct 8, 2024

This creates a new TryBatchInsert function in trie. All key-value insertion
pairs are passed together. If the resolved root node is a full node, the
insertion pairs are partitioned by the first byte in their keys. Children
subtries of the full node are inserted in parallel. If the resolved root node is
not a full node, the insertion pairs are inserted sequentially.

  • Result comparing BenchmarkNormalInsert to BenchmarkBatchInsert
goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/trie
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
               │ normal.txt  │              batch.txt               │
               │   sec/op    │    sec/op     vs base                │
NormalInsert-8   6.823m ± 7%   3.716m ± 18%  -45.54% (p=0.000 n=10)
  • BenchmarkManyStorageUpdate with mainnet data on a machine with 4 CPUs
go test -test.v -run=^$ -bench=BenchmarkManyStorageUpdate -benchtime=5x

goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/core
cpu: Intel(R) Xeon(R) CPU @ 2.30GHz

Before this PR
BenchmarkManyStorageUpdate-4           5        1444317082 ns/op

After this PR
BenchmarkManyStorageUpdate-4           5         792899625 ns/op

This creates a new TryBatchInsert function in trie. All key-value insertion
pairs are passed together. If the resolved root node is a full node, the
insertion pairs are partitioned by the first byte in their keys. Children
subtries of the full node are inserted in parallel. If the resolved root node is
not a full node, the insertion pairs are inserted sequentially.

Result comparing BenchmarkNormalInsert to BenchmarkBatchInsert

goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/trie
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
               │ normal.txt  │              batch.txt               │
               │   sec/op    │    sec/op     vs base                │
NormalInsert-8   6.823m ± 7%   3.716m ± 18%  -45.54% (p=0.000 n=10)
@minh-bq minh-bq force-pushed the parallel-insert-trie branch 3 times, most recently from 8f1f1e4 to 0fe75e8 Compare October 10, 2024 08:52
@minh-bq minh-bq marked this pull request as ready for review October 10, 2024 09:09
When there are more than parallelInsertThreshold (currently set to 500) pending
storages update to storage trie, we will use the new TryBatchInsert to parallel
insert these storages if possible.
This benchmark is intended to be used with mainnet data. The benchmark includes
many storage updates to Axie contract's storage.
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