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/state/snapshot: fix benchmarks #23804

Merged
merged 1 commit into from
Oct 26, 2021
Merged

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Oct 25, 2021

Fixes a benchmark
Before:

[user@work core]$ go test ./state/snapshot/ -run - -bench Journal
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x5aaafc]

goroutine 7 [running]:
github.com/ethereum/go-ethereum/core/rawdb.WriteSnapshotGenerator({0x0, 0x0}, {0xc000c062f0, 0x4, 0xc0348bf130})
	/home/user/go/src/github.com/ethereum/go-ethereum/core/rawdb/accessors_snapshot.go:154 +0x3c
github.com/ethereum/go-ethereum/core/state/snapshot.journalProgress({0x0, 0x0}, {0x0, 0x0, 0x0}, 0x0)
	/home/user/go/src/github.com/ethereum/go-ethereum/core/state/snapshot/generate.go:203 +0x392
github.com/ethereum/go-ethereum/core/state/snapshot.(*diskLayer).Journal(0xc00015a000, 0x0)

@@ -388,7 +451,9 @@ func BenchmarkJournal(b *testing.B) {
}
return newDiffLayer(parent, common.Hash{}, destructs, accounts, storage)
}
layer := snapshot(new(diskLayer))
disk := new(diskLayer)
disk.diskdb = noOpDb{}
Copy link
Member

Choose a reason for hiding this comment

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

I think it's also OK to use the memorydb here. Since no real db ops will happen during the Journal benchmark,
but I'm also fine with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True dat, I'll just do that then, and simplify the code

@holiman holiman merged commit 526c3f6 into ethereum:master Oct 26, 2021
@holiman holiman added this to the 1.10.12 milestone Oct 26, 2021
sidhujag pushed a commit to syscoin/go-ethereum that referenced this pull request Oct 26, 2021
@holiman holiman deleted the benchfix_2 branch November 10, 2021 18:32
yongjun925 pushed a commit to DODOEX/go-ethereum that referenced this pull request Dec 3, 2022
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