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
BenchmarkManyStorageUpdate with mainnet data on a machine with 4 CPUs
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