core: more efficient nonce-update in txpool (#22231)
* Adjust pending nonce update operation Benchmark the speed of transaction insertion under multiple accounts core: fix rebase issues + docstring core: make benchmark test use sync:ed method * core: address review comments * core: add memreport to benchmark Co-authored-by: WeiLoy <wei_loy@163.com>
This commit is contained in:
committed by
GitHub
parent
f49e90e32c
commit
03bc8b7858
@ -2540,3 +2540,24 @@ func BenchmarkInsertRemoteWithAllLocals(b *testing.B) {
|
||||
pool.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmarks the speed of batch transaction insertion in case of multiple accounts.
|
||||
func BenchmarkPoolMultiAccountBatchInsert(b *testing.B) {
|
||||
// Generate a batch of transactions to enqueue into the pool
|
||||
pool, _ := setupTxPool()
|
||||
defer pool.Stop()
|
||||
b.ReportAllocs()
|
||||
batches := make(types.Transactions, b.N)
|
||||
for i := 0; i < b.N; i++ {
|
||||
key, _ := crypto.GenerateKey()
|
||||
account := crypto.PubkeyToAddress(key.PublicKey)
|
||||
pool.currentState.AddBalance(account, big.NewInt(1000000))
|
||||
tx := transaction(uint64(0), 100000, key)
|
||||
batches[i] = tx
|
||||
}
|
||||
// Benchmark importing the transactions into the queue
|
||||
b.ResetTimer()
|
||||
for _, tx := range batches {
|
||||
pool.AddRemotesSync([]*types.Transaction{tx})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user