Skip to content

Commit

Permalink
eth/filters, p2p/simulations: fix benchmarks (ethereum#23806)
Browse files Browse the repository at this point in the history
Some benchmarks in eth/filters were not good: they weren't reproducible, relying on geth chaindata to be present.

Another one was rejected because the receipt was lacking a backing transcation.

The p2p simulation benchmark had a lot of the warnings below, due to the framework calling both
Stop() and Close(). Apparently, the simulated adapter is the only implementation which has a Close(),
and there is no need to call both Stop and Close on it.
  • Loading branch information
holiman authored and zzyalbert committed Nov 26, 2021
1 parent 096383c commit a7e5c73
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions eth/filters/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func BenchmarkBloomBits32k(b *testing.B) {
const benchFilterCnt = 2000

func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
b.Skip("test disabled: this tests presume (and modify) an existing datadir.")
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
b.Log("Running bloombits benchmark section size:", sectionSize)

Expand Down Expand Up @@ -155,6 +156,7 @@ func clearBloomBits(db ethdb.Database) {
}

func BenchmarkNoBloomBits(b *testing.B) {
b.Skip("test disabled: this tests presume (and modify) an existing datadir.")
benchDataDir := node.DefaultDataDir() + "/geth/chaindata"
b.Log("Running benchmark without bloombits")
db, err := rawdb.NewLevelDBDatabase(benchDataDir, 128, 1024, "", false)
Expand Down
4 changes: 4 additions & 0 deletions eth/filters/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ func BenchmarkFilters(b *testing.B) {
case 2403:
receipt := makeReceipt(addr1)
gen.AddUncheckedReceipt(receipt)
gen.AddUncheckedTx(types.NewTransaction(999, common.HexToAddress("0x999"), big.NewInt(999), 999, gen.BaseFee(), nil))
case 1034:
receipt := makeReceipt(addr2)
gen.AddUncheckedReceipt(receipt)
gen.AddUncheckedTx(types.NewTransaction(999, common.HexToAddress("0x999"), big.NewInt(999), 999, gen.BaseFee(), nil))
case 34:
receipt := makeReceipt(addr3)
gen.AddUncheckedReceipt(receipt)
gen.AddUncheckedTx(types.NewTransaction(999, common.HexToAddress("0x999"), big.NewInt(999), 999, gen.BaseFee(), nil))
case 99999:
receipt := makeReceipt(addr4)
gen.AddUncheckedReceipt(receipt)
gen.AddUncheckedTx(types.NewTransaction(999, common.HexToAddress("0x999"), big.NewInt(999), 999, gen.BaseFee(), nil))

}
})
Expand Down
1 change: 1 addition & 0 deletions eth/tracers/tracers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ func BenchmarkTransactionTrace(b *testing.B) {
Time: new(big.Int).SetUint64(uint64(5)),
Difficulty: big.NewInt(0xffffffff),
GasLimit: gas,
BaseFee: big.NewInt(8),
}
alloc := core.GenesisAlloc{}
// The code pushes 'deadbeef' into memory, then the other params, and calls CREATE2, then returns
Expand Down
7 changes: 0 additions & 7 deletions p2p/simulations/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"math/rand"
"sync"
"time"
Expand Down Expand Up @@ -695,12 +694,6 @@ func (net *Network) Shutdown() {
if err := node.Stop(); err != nil {
log.Warn("Can't stop node", "id", node.ID(), "err", err)
}
// If the node has the close method, call it.
if closer, ok := node.Node.(io.Closer); ok {
if err := closer.Close(); err != nil {
log.Warn("Can't close node", "id", node.ID(), "err", err)
}
}
}
close(net.quitc)
}
Expand Down

0 comments on commit a7e5c73

Please sign in to comment.