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: write benchmarks to compare performance of store v1/v2 under different load scenarios #10722

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
register substore before get GetKVStore
  • Loading branch information
adu-web3 committed Mar 11, 2022
commit 3bce91ef3a26360b9b460005132270d269fbff36
18 changes: 16 additions & 2 deletions store/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

var (
cacheSize = 100
skey_1 = types.NewKVStoreKey("store1")
)

func randBytes(numBytes int) []byte {
Expand Down Expand Up @@ -104,6 +105,15 @@ type storeV2 struct {
storev2types.KVStore
}

func simpleStoreConfig() (storev2.StoreConfig, error) {
opts := storev2.DefaultStoreConfig()
err := opts.RegisterSubstore(skey_1.Name(), types.StoreTypePersistent)
if err != nil {
return storev2.StoreConfig{}, err
}
return opts, nil
}

func sampleOperation(p percentages) string {
ops := []string{"Has", "Get", "Set", "Delete"}
thresholds := []int{p.has, p.has + p.get, p.has + p.get + p.set}
Expand Down Expand Up @@ -249,7 +259,11 @@ func newStore(version int, dbBackend interface{}, cID *types.CommitID, cacheSize
if !ok {
return nil, fmt.Errorf("unsupported db type")
}
root, err := storev2.NewStore(db, storev2.DefaultStoreConfig())
simpleStoreConfig, err := simpleStoreConfig()
if err != nil {
return nil, err
}
root, err := storev2.NewStore(db, simpleStoreConfig)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -284,7 +298,7 @@ func runSuite(b *testing.B, version int, dbBackendTypes []tmdb.BackendType, dir
}

// run deterministic operations subbenchmarks for various scenarios
c := counts{has: 5, get: 20, set: 5, delete: 1}
c := counts{has: 200, get: 5500, set: 4000, delete: 300}
sampledCounts := []counts{c}
benchmarks = generateBenchmarks(dbBackendTypes, nil, sampledCounts)
values := prepareValues()
Expand Down