Skip to content

Commit

Permalink
all: skip noisy/faulty benchmarks + add b.ReportAllocs for every benc…
Browse files Browse the repository at this point in the history
…hmark (bp #8856) (#8859)

* all: skip noisy/faulty benchmarks + add b.ReportAllocs for every benchmark (#8856)

* Skips very noisy benchmarks that end up running only for b.N=1 because
their entire time is spent in setup, and varying parameters doesn't change
much given that the number of stores is what dominates the expense. To
ensure we can provide reliable benchmarks, progressively for the project,
skip these until there is a proper re-work of what the benchmarks need to do

* Previously sub-benchmarks: b.Run(...) did not b.ReportAllocs() due to a faulty
assumption that invoking b.ReportAllocs() at the top would be inherited by
all sub-benchmarks. This change fixes that

Fixes #8779
Fixes #8855

Co-authored-by: Alessio Treglia <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit b9f3db1)

* Remove stray code that got pulled in by mergify but not essential

Co-authored-by: Emmanuel T Odeke <[email protected]>
Co-authored-by: Alessio Treglia <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2021
1 parent c6462e6 commit 1d98b2a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions crypto/armor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func BenchmarkBcryptGenerateFromPassword(b *testing.B) {
for securityParam := 9; securityParam < 16; securityParam++ {
param := securityParam
b.Run(fmt.Sprintf("benchmark-security-param-%d", param), func(b *testing.B) {
b.ReportAllocs()
saltBytes := tmcrypto.CRandBytes(16)
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand Down
6 changes: 6 additions & 0 deletions store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ func BenchmarkMultistoreSnapshotRestore1M(b *testing.B) {
}

func benchmarkMultistoreSnapshot(b *testing.B, stores uint8, storeKeys uint64) {
b.Skip("Noisy with slow setup time, please see https://github.com/cosmos/cosmos-sdk/issues/8855.")

b.ReportAllocs()
b.StopTimer()
source := newMultiStoreWithGeneratedData(dbm.NewMemDB(), stores, storeKeys)
version := source.LastCommitID().Version
Expand Down Expand Up @@ -716,6 +719,9 @@ func benchmarkMultistoreSnapshot(b *testing.B, stores uint8, storeKeys uint64) {
}

func benchmarkMultistoreSnapshotRestore(b *testing.B, stores uint8, storeKeys uint64) {
b.Skip("Noisy with slow setup time, please see https://github.com/cosmos/cosmos-sdk/issues/8855.")

b.ReportAllocs()
b.StopTimer()
source := newMultiStoreWithGeneratedData(dbm.NewMemDB(), stores, storeKeys)
version := uint64(source.LastCommitID().Version)
Expand Down
2 changes: 2 additions & 0 deletions types/coin_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func coinName(suffix int) string {
func BenchmarkCoinsAdditionIntersect(b *testing.B) {
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
return func(b *testing.B) {
b.ReportAllocs()
coinsA := Coins(make([]Coin, numCoinsA))
coinsB := Coins(make([]Coin, numCoinsB))

Expand Down Expand Up @@ -41,6 +42,7 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) {
func BenchmarkCoinsAdditionNoIntersect(b *testing.B) {
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
return func(b *testing.B) {
b.ReportAllocs()
coinsA := Coins(make([]Coin, numCoinsA))
coinsB := Coins(make([]Coin, numCoinsB))

Expand Down
1 change: 1 addition & 0 deletions x/auth/keeper/keeper_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func BenchmarkAccountMapperGetAccountFound(b *testing.B) {
}

func BenchmarkAccountMapperSetAccount(b *testing.B) {
b.ReportAllocs()
app, ctx := createTestApp(false)

b.ResetTimer()
Expand Down
1 change: 1 addition & 0 deletions x/bank/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) {
}

func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) {
b.ReportAllocs()
// Add an account at genesis
acc := authtypes.BaseAccount{
Address: addr1.String(),
Expand Down

0 comments on commit 1d98b2a

Please sign in to comment.