From 99c0c1818a6fae462e1c10693b0df6bde119bfed Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 15 Oct 2024 11:04:05 +0200 Subject: [PATCH] core: add better benchmark numbers --- core/blockchain.go | 6 +++--- core/blockchain_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index c91c72a44e..b3a9ed21a3 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2273,9 +2273,9 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { // reads should be blocked until the mutation is complete. bc.txLookupLock.Lock() - var stats runtime.MemStats - runtime.ReadMemStats(&stats) - panic(stats.HeapInuse) + //var stats runtime.MemStats + //runtime.ReadMemStats(&stats) + //panic(stats.HeapInuse) // Insert the new chain segment in incremental order, from the old // to the new. The new chain head (newChain[0]) is not inserted here, diff --git a/core/blockchain_test.go b/core/blockchain_test.go index ae2eedd3dd..b518819a21 100644 --- a/core/blockchain_test.go +++ b/core/blockchain_test.go @@ -4249,8 +4249,8 @@ func BenchmarkReorg(b *testing.B) { defer blockchain.Stop() // Insert an easy and a difficult chain afterwards - easyBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(500)) - diffBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(500)) + easyBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(50000)) + diffBlocks, _ := GenerateChain(params.TestChainConfig, blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash()), ethash.NewFaker(), db, chainLength, genValueTx(50000)) if _, err := blockchain.InsertChain(easyBlocks); err != nil { b.Fatalf("failed to insert easy chain: %v", err) @@ -4261,5 +4261,5 @@ func BenchmarkReorg(b *testing.B) { } } -// BenchmarkReorg-8 10000 362204 ns/op 271290 B/op 1256 allocs/op 151412736 bytes of heap used -// BenchmarkReorg-8 10000 381835 ns/op 276959 B/op 1324 allocs/op 152895488 bytes of heap used +// Master: BenchmarkReorg-8 10000 899591 ns/op 820154 B/op 1440 allocs/op 1549443072 bytes of heap used +// WithoutOldChain: BenchmarkReorg-8 10000 1147281 ns/op 943163 B/op 1564 allocs/op 1163870208 bytes of heap used