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

test: Add query benchmarks #13657

Closed
wants to merge 3 commits into from
Closed

test: Add query benchmarks #13657

wants to merge 3 commits into from

Conversation

facundomedica
Copy link
Member

Description

Closes: #13605


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Nov 2, 2022

Codecov Report

Merging #13657 (f8e14b1) into main (ad08ec4) will increase coverage by 1.75%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13657      +/-   ##
==========================================
+ Coverage   54.69%   56.44%   +1.75%     
==========================================
  Files         645      648       +3     
  Lines       55745    56249     +504     
==========================================
+ Hits        30491    31752    +1261     
+ Misses      22764    21934     -830     
- Partials     2490     2563      +73     
Impacted Files Coverage Δ
server/mock/tx.go 53.33% <0.00%> (-11.38%) ⬇️
x/gov/migrations/v4/store.go 81.63% <0.00%> (-8.03%) ⬇️
baseapp/msg_service_router.go 77.46% <0.00%> (-7.83%) ⬇️
x/slashing/module.go 52.38% <0.00%> (-7.39%) ⬇️
x/distribution/types/codec.go 55.55% <0.00%> (-6.95%) ⬇️
x/mint/module.go 60.43% <0.00%> (-5.87%) ⬇️
x/bank/module.go 55.44% <0.00%> (-5.72%) ⬇️
x/group/module/module.go 48.05% <0.00%> (-4.45%) ⬇️
types/utils.go 85.18% <0.00%> (-4.43%) ⬇️
x/staking/module.go 54.70% <0.00%> (-4.28%) ⬇️
... and 106 more

@facundomedica
Copy link
Member Author

goos: linux
goarch: amd64
pkg: cosmossdk.io/simapp
cpu: AMD Ryzen 9 5950X 16-Core Processor            
BenchmarkQueryBalance-28                 	65826526	      1991 ns/op	    1248 B/op	      23 allocs/op
BenchmarkQueryAllBalances-28             	 5324523	     25964 ns/op	   13880 B/op	     194 allocs/op
BenchmarkQueryVotes-28                   	   46802	   3036841 ns/op	 2882321 B/op	   58778 allocs/op
BenchmarkQuerySigningInfos-28            	  159805	    837972 ns/op	  830744 B/op	   14910 allocs/op
BenchmarkQueryValidatorDelegations-28    	      55	2344313919 ns/op	1734644973 B/op	28169866 allocs/op
PASS
ok  	cosmossdk.io/simapp	30403.562s

@facundomedica
Copy link
Member Author

facundomedica commented Nov 23, 2022

Final results:

go test -benchmem -timeout=120h -benchtime=120s -run=^$ -bench "^(BenchmarkQueryBalance|BenchmarkQueryAllBalances|BenchmarkQueryVotes|BenchmarkQuerySigningInfos|BenchmarkQueryValidatorDelegations)$" -memprofile memprofile.out -cpuprofile profile.out cosmossdk.io/simapp

goos: linux
goarch: amd64
pkg: cosmossdk.io/simapp
cpu: AMD Ryzen 9 5950X 16-Core Processor            
BenchmarkQueryBalance-28                 	66626565	      1993 ns/op	    1248 B/op	      23 allocs/op
BenchmarkQueryAllBalances-28             	 5418576	     26516 ns/op	   13880 B/op	     194 allocs/op
BenchmarkQueryVotes-28                   	   46556	   3026516 ns/op	 2882343 B/op	   58778 allocs/op
BenchmarkQuerySigningInfos-28            	  162439	    835128 ns/op	  830759 B/op	   14910 allocs/op
BenchmarkQueryValidatorDelegations-28    	      60	2359649179 ns/op	1735087374 B/op	28170831 allocs/op
PASS
ok  	cosmossdk.io/simapp	31174.6

The zip file contains both memory and cpu profiles
profiles.zip

Comment on lines +23 to +31
func setup() {
// TODO: change this
db, err := dbm.NewGoLevelDB("application", "/Users/facundo/Downloads/testinghomedir/data")
if err != nil {
panic(err)
}
logger := log.TestingLogger()
app = simapp.NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome("/Users/facundo/Downloads/testinghomedir"))
}

Choose a reason for hiding this comment

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

Please fix with e.g. t.TempDir

@peterbourgon
Copy link

peterbourgon commented Nov 25, 2022

Any suggestion?

$ go test -v -run=xxx -bench='(BenchmarkQueryBalance|BenchmarkQueryAllBalances|BenchmarkQueryVotes|BenchmarkQuerySigningInfos|BenchmarkQueryValidatorDelegations)' .
goos: darwin
goarch: arm64
pkg: cosmossdk.io/simapp
BenchmarkQueryBalance
    benchs_test.go:47: wrong balance 0 742318
--- FAIL: BenchmarkQueryBalance
BenchmarkQueryAllBalances
    benchs_test.go:67: wrong balance 0 742318
--- FAIL: BenchmarkQueryAllBalances
BenchmarkQueryVotes
    benchs_test.go:109: wrong number of votes 0
--- FAIL: BenchmarkQueryVotes
BenchmarkQuerySigningInfos
    benchs_test.go:129: wrong number of signing infos 0
--- FAIL: BenchmarkQuerySigningInfos
BenchmarkQueryValidatorDelegations
    benchs_test.go:151: wrong number of delegations 0
--- FAIL: BenchmarkQueryValidatorDelegations
FAIL
exit status 1
FAIL    cosmossdk.io/simapp     0.559s
FAIL

@facundomedica
Copy link
Member Author

@peterbourgon the benchmarks in the go files, right now, are meant to be ran against a directory that contains Gaia's state. Currently, they are a PoC than an actual benchmark.
I'll go back to this and change it to something that first creates a bunch of accounts, transactions, etc and runs these benchmarks.

@peterbourgon
Copy link

Gotcha! And totally fair given this is still in draft 😉 Willing to do whatever manual work, if you can lay it out in a reasonably reproducible way. But also happy to wait for your updates.

@tac0turtle
Copy link
Member

closing this as it has reached our 30 day window of inactivity when keeping prs open

@tac0turtle tac0turtle closed this Dec 16, 2022
@tac0turtle tac0turtle deleted the facu/app-benchmarks branch April 14, 2023 10:26
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.

Create benchmarks for queries
3 participants