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: fix benchmark tests #23803

Merged
merged 2 commits into from
Oct 27, 2021
Merged

core: fix benchmark tests #23803

merged 2 commits into from
Oct 27, 2021

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Oct 25, 2021

Our benchmarks have bitrotted pretty heavily, so this PR is the first in a series of fixups. This PR fixes the following crashes:

BenchmarkInsertChain_empty_diskdb-6                      	    6121	    226293 ns/op	  196298 B/op	     587 allocs/op
panic: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 0 baseFee: 875000000

goroutine 45758 [running]:
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTxWithChain(0xc0000bc0a0, 0xaa6e98, 0xc002704480)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:108 +0x33d
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTx(...)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:90
github.com/ethereum/go-ethereum/core.genValueTx.func1(0xaa7100, 0xc000cfc028)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:90 +0x1be
github.com/ethereum/go-ethereum/core.GenerateChain.func1(0x0, 0xc0000e8000, 0xc000488d00)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:222 +0x3e6
github.com/ethereum/go-ethereum/core.GenerateChain(0xc0065fbe10, 0xc0000e8000, {0xaaed68, 0xc0000f20e0}, {0xab2618, 0xc0000f45c0}, 0x1, 0xc002c5a000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:245 +0x22d
github.com/ethereum/go-ethereum/core.benchInsertChain(0xc003aca240, 0x0, 0xc002c5a000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:174 +0x49f
github.com/ethereum/go-ethereum/core.BenchmarkInsertChain_valueTx_memdb(0xc003aca240)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:44 +0x34
testing.(*B).runN(0xc003aca240, 0x1)
	/usr/local/go/src/testing/benchmark.go:192 +0x126
testing.(*B).run1.func1()
	/usr/local/go/src/testing/benchmark.go:232 +0x59
created by testing.(*B).run1
	/usr/local/go/src/testing/benchmark.go:225 +0xa5
exit status 2
FAIL	github.com/ethereum/go-ethereum/core	4.546s
panic: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 0 baseFee: 875000000

goroutine 134800 [running]:
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTxWithChain(0xc00015a0a0, 0xaa6ed8, 0xc00021c6c0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:108 +0x33d
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTx(...)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:90
github.com/ethereum/go-ethereum/core.genTxRing.func1(0xaa7140, 0xc000122048)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:143 +0x7c
github.com/ethereum/go-ethereum/core.GenerateChain.func1(0x0, 0xc00018c000, 0xc002aa81a0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:222 +0x3e6
github.com/ethereum/go-ethereum/core.GenerateChain(0xc00112de10, 0xc00018c000, {0xaaeda8, 0xc0001960e0}, {0xab2658, 0xc000118230}, 0x1, 0xc0036a8000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:245 +0x22d
github.com/ethereum/go-ethereum/core.benchInsertChain(0xc0023a2000, 0x0, 0xc0036a8000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:186 +0x49f
github.com/ethereum/go-ethereum/core.BenchmarkInsertChain_ring200_memdb(0xc0023a2000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:62 +0x34
testing.(*B).runN(0xc0023a2000, 0x1)
	/usr/local/go/src/testing/benchmark.go:192 +0x126
testing.(*B).run1.func1()
	/usr/local/go/src/testing/benchmark.go:232 +0x59
created by testing.(*B).run1
	/usr/local/go/src/testing/benchmark.go:225 +0xa5
exit status 2
FAIL	github.com/ethereum/go-ethereum/core	23.355s
FAIL
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x80706d]

goroutine 165042 [running]:
github.com/ethereum/go-ethereum/core/types.(*Block).NumberU64(...)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/types/block.go:292
github.com/ethereum/go-ethereum/core.(*BlockChain).SetHeadBeyondRoot(0xc0000da000, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain.go:613 +0x20d
github.com/ethereum/go-ethereum/core.(*BlockChain).SetHead(0x5fdbcb, 0xc000c06ab0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain.go:485 +0x27
github.com/ethereum/go-ethereum/core.(*BlockChain).ResetWithGenesisBlock(0xc0000da000, 0xc0000e8120)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain.go:672 +0x5d
github.com/ethereum/go-ethereum/core.(*BlockChain).Reset(0xd86bc0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain.go:665 +0x25
github.com/ethereum/go-ethereum/core.(*BlockChain).loadLastState(0xc0000da000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain.go:433 +0x1072
github.com/ethereum/go-ethereum/core.NewBlockChain({_, _}, _, _, {_, _}, {0x0, {0x0, 0x0}, 0x0, ...}, ...)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain.go:282 +0x985
github.com/ethereum/go-ethereum/core.benchReadChain(0xc005a2a240, 0x0, 0x2710)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:316 +0x430
github.com/ethereum/go-ethereum/core.BenchmarkChainRead_header_10k(0xc005a2a240)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:214 +0x25
testing.(*B).runN(0xc005a2a240, 0x1)
	/usr/local/go/src/testing/benchmark.go:192 +0x126
testing.(*B).run1.func1()
	/usr/local/go/src/testing/benchmark.go:232 +0x59
created by testing.(*B).run1
	/usr/local/go/src/testing/benchmark.go:225 +0xa5
exit status 2
FAIL	github.com/ethereum/go-ethereum/core	74.790s
FAIL
panic: reflect: call of reflect.Value.Type on zero Value

goroutine 183560 [running]:
reflect.Value.Type({0x0, 0x0, 0xc00039f078})
	/usr/local/go/src/reflect/value.go:2249 +0x12e
github.com/ethereum/go-ethereum/rlp.(*encbuf).encode(0xd86fa0, {0x0, 0x0})
	/home/user/go/src/github.com/ethereum/go-ethereum/rlp/encode.go:152 +0xb8
github.com/ethereum/go-ethereum/rlp.EncodeToBytes({0x0, 0x0})
	/home/user/go/src/github.com/ethereum/go-ethereum/rlp/encode.go:74 +0xe9
github.com/ethereum/go-ethereum/trie.(*cachedNode).rlp(0xc006c98b40)
	/home/user/go/src/github.com/ethereum/go-ethereum/trie/database.go:167 +0x51
github.com/ethereum/go-ethereum/trie.(*Database).commit(0xc0047b0410, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
	/home/user/go/src/github.com/ethereum/go-ethereum/trie/database.go:772 +0x173
github.com/ethereum/go-ethereum/trie.(*Database).Commit(0xc0047b0410, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
	/home/user/go/src/github.com/ethereum/go-ethereum/trie/database.go:717 +0x1bc
github.com/ethereum/go-ethereum/core.(*BlockChain).Stop(0xfdee4e5ec691f529)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain.go:814 +0x755
github.com/ethereum/go-ethereum/core.benchReadChain(0xc0070fad80, 0x1, 0x2710)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:330 +0x265
github.com/ethereum/go-ethereum/core.BenchmarkChainRead_full_10k(0xc0070fad80)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/bench_test.go:217 +0x25
testing.(*B).runN(0xc0070fad80, 0x1)
	/usr/local/go/src/testing/benchmark.go:192 +0x126
testing.(*B).run1.func1()
	/usr/local/go/src/testing/benchmark.go:232 +0x59
created by testing.(*B).run1
	/usr/local/go/src/testing/benchmark.go:225 +0xa5
exit status 2
FAIL	github.com/ethereum/go-ethereum/core	78.065s
panic: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 1 baseFee: 875000000

goroutine 50 [running]:
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTxWithChain(0xc00015a0a0, 0xaa7ff8, 0xc000124840)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:108 +0x33d
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTx(...)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:90
github.com/ethereum/go-ethereum/core.benchmarkLargeNumberOfValueToNonexisting.func1(0x0, 0xc00015a0a0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain_test.go:2392 +0xea
github.com/ethereum/go-ethereum/core.GenerateChain.func1(0x0, 0xc00018c000, 0xc0001f1ba0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:222 +0x3e6
github.com/ethereum/go-ethereum/core.GenerateChain(0xc000467e20, 0xc00018c000, {0xaaff28, 0xc000196000}, {0xab37d8, 0xc00044a000}, 0x1, 0xc000467db0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:245 +0x22d
github.com/ethereum/go-ethereum/core.benchmarkLargeNumberOfValueToNonexisting(0xc00016e000, 0x3e8, 0x1, 0x9fe8f0, 0x9fe8f8)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain_test.go:2396 +0x525
github.com/ethereum/go-ethereum/core.BenchmarkBlockChain_1x1000ValueTransferToNonexisting(0xc00016e000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/blockchain_test.go:2431 +0x31
testing.(*B).runN(0xc00016e000, 0x1)
	/usr/local/go/src/testing/benchmark.go:192 +0x126
testing.(*B).run1.func1()
	/usr/local/go/src/testing/benchmark.go:232 +0x59
created by testing.(*B).run1
	/usr/local/go/src/testing/benchmark.go:225 +0xa5
exit status 2
FAIL	github.com/ethereum/go-ethereum/core	0.082s
panic: insufficient funds for gas * price + value: address 0x71562b71999873DB5b286dF957af199Ec94617F7 have 20038281250000 want 33496093750000

goroutine 128047 [running]:
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTxWithChain(0xc00cfd2280, 0xaa7fb8, 0xc004178120)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:108 +0x33d
github.com/ethereum/go-ethereum/core.(*BlockGen).AddTx(...)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:90
github.com/ethereum/go-ethereum/core.getBlock.func1(0x2, 0xc00cfd2280)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/rlp_test.go:59 +0xbf
github.com/ethereum/go-ethereum/core.GenerateChain.func1(0x2, 0xc0070a4120, 0xc00154c820)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:222 +0x3e6
github.com/ethereum/go-ethereum/core.GenerateChain(0xc000357d68, 0xc0070a4000, {0xaafee8, 0xc0000f2620}, {0xab3798, 0xc006228000}, 0x3, 0xc000357ce0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/chain_makers.go:245 +0x22d
github.com/ethereum/go-ethereum/core.getBlock(0xc8, 0x2, 0x32)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/rlp_test.go:52 +0x3ec
github.com/ethereum/go-ethereum/core.BenchmarkHashing(0xc006f94000)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/rlp_test.go:149 +0x45
testing.(*B).runN(0xc006f94000, 0x1)
	/usr/local/go/src/testing/benchmark.go:192 +0x126
testing.(*B).run1.func1()
	/usr/local/go/src/testing/benchmark.go:232 +0x59
created by testing.(*B).run1
	/usr/local/go/src/testing/benchmark.go:225 +0xa5
exit status 2
FAIL	github.com/ethereum/go-ethereum/core	207.537s
FAIL

This test wasn't using b.N, and has been fixed

BenchmarkTxListAdd-6                                     	1000000000	         0.1420 ns/op

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@holiman holiman added this to the 1.10.12 milestone Oct 27, 2021
@holiman holiman merged commit eab4d89 into ethereum:master Oct 27, 2021
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Oct 27, 2021
Fixes crashes in various benchmarks in the core package
@holiman holiman deleted the fix_benches branch November 10, 2021 18:32
yongjun925 pushed a commit to DODOEX/go-ethereum that referenced this pull request Dec 3, 2022
Fixes crashes in various benchmarks in the core package
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.

2 participants