From 3b35896fde608aded7bc11ca65f00472619752f4 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Fri, 4 Oct 2024 15:43:12 +0200 Subject: [PATCH 01/13] enhance merged iter --- server/v2/stf/branch/changeset.go | 3 +- server/v2/stf/branch/mergeiter.go | 307 ++++++++++++------------------ 2 files changed, 121 insertions(+), 189 deletions(-) diff --git a/server/v2/stf/branch/changeset.go b/server/v2/stf/branch/changeset.go index 07a29345aee7..8aac45f8953f 100644 --- a/server/v2/stf/branch/changeset.go +++ b/server/v2/stf/branch/changeset.go @@ -3,6 +3,7 @@ package branch import ( "bytes" "errors" + "fmt" "github.com/tidwall/btree" ) @@ -165,7 +166,7 @@ func (mi *memIterator) Close() error { // Otherwise, it returns nil. func (mi *memIterator) Error() error { if !mi.Valid() { - return errInvalidIterator + return fmt.Errorf("invalid iterator") } return nil } diff --git a/server/v2/stf/branch/mergeiter.go b/server/v2/stf/branch/mergeiter.go index e71b88cffc42..c35ed9ddbb30 100644 --- a/server/v2/stf/branch/mergeiter.go +++ b/server/v2/stf/branch/mergeiter.go @@ -8,228 +8,159 @@ import ( ) // mergedIterator merges a parent Iterator and a cache Iterator. -// The cache iterator may return nil keys to signal that an item -// had been deleted (but not deleted in the parent). -// If the cache iterator has the same key as the parent, the -// cache shadows (overrides) the parent. -type mergedIterator struct { - parent corestore.Iterator - cache corestore.Iterator - ascending bool - - valid bool +// The cache iterator may contain items that shadow or override items in the parent iterator. +// If the cache iterator has the same key as the parent, the cache's value takes precedence. +// Deleted items in the cache (indicated by nil values) are skipped. +type mergedIterator[Parent, Cache corestore.Iterator] struct { + parent Parent // Iterator for the parent store + cache Cache // Iterator for the cache store + ascending bool // Direction of iteration + valid bool // Indicates if the iterator is in a valid state + currKey []byte // Current key pointed by the iterator + currValue []byte // Current value corresponding to currKey + err error // Error encountered during iteration } -var _ corestore.Iterator = (*mergedIterator)(nil) +// Ensure mergedIterator implements the corestore.Iterator interface. +var _ corestore.Iterator = (*mergedIterator[corestore.Iterator, corestore.Iterator])(nil) -// mergeIterators merges two iterators. -func mergeIterators(parent, cache corestore.Iterator, ascending bool) corestore.Iterator { - iter := &mergedIterator{ +// mergeIterators creates a new merged iterator from parent and cache iterators. +// The 'ascending' parameter determines the direction of iteration. +func mergeIterators[Parent, Cache corestore.Iterator](parent Parent, cache Cache, ascending bool) *mergedIterator[Parent, Cache] { + iter := &mergedIterator[Parent, Cache]{ parent: parent, cache: cache, ascending: ascending, } - - iter.valid = iter.skipUntilExistsOrInvalid() + iter.advance() // Initialize the iterator by advancing to the first valid item return iter } -// Domain implements Iterator. -// Returns parent domain because cache and parent domains are the same. -func (iter *mergedIterator) Domain() (start, end []byte) { - return iter.parent.Domain() -} - -// Valid implements Iterator. -func (iter *mergedIterator) Valid() bool { - return iter.valid -} - -// Next implements Iterator -func (iter *mergedIterator) Next() { - iter.assertValid() - - switch { - case !iter.parent.Valid(): - // If parent is invalid, get the next cache item. - iter.cache.Next() - case !iter.cache.Valid(): - // If cache is invalid, get the next parent item. - iter.parent.Next() - default: - // Both are valid. Compare keys. - keyP, keyC := iter.parent.Key(), iter.cache.Key() - switch iter.compare(keyP, keyC) { - case -1: // parent < cache - iter.parent.Next() - case 0: // parent == cache - iter.parent.Next() - iter.cache.Next() - case 1: // parent > cache - iter.cache.Next() - } - } - iter.valid = iter.skipUntilExistsOrInvalid() -} - -// Key implements Iterator -func (iter *mergedIterator) Key() []byte { - iter.assertValid() - - // If parent is invalid, get the cache key. - if !iter.parent.Valid() { - return iter.cache.Key() - } - - // If cache is invalid, get the parent key. - if !iter.cache.Valid() { - return iter.parent.Key() - } - - // Both are valid. Compare keys. - keyP, keyC := iter.parent.Key(), iter.cache.Key() - - cmp := iter.compare(keyP, keyC) - switch cmp { - case -1: // parent < cache - return keyP - case 0: // parent == cache - return keyP - case 1: // parent > cache - return keyC - default: - panic("invalid compare result") - } +// Domain returns the start and end range of the iterator. +// It delegates to the parent iterator as both iterators share the same domain. +func (i *mergedIterator[Parent, Cache]) Domain() (start, end []byte) { + return i.parent.Domain() } -// Value implements Iterator -func (iter *mergedIterator) Value() []byte { - iter.assertValid() - - // If parent is invalid, get the cache value. - if !iter.parent.Valid() { - return iter.cache.Value() - } - - // If cache is invalid, get the parent value. - if !iter.cache.Valid() { - return iter.parent.Value() - } - - // Both are valid. Compare keys. - keyP, keyC := iter.parent.Key(), iter.cache.Key() - - cmp := iter.compare(keyP, keyC) - switch cmp { - case -1: // parent < cache - return iter.parent.Value() - case 0: // parent == cache - return iter.cache.Value() - case 1: // parent > cache - return iter.cache.Value() - default: - panic("invalid comparison result") - } +// Valid checks if the iterator is in a valid state. +// It returns true if the iterator has not reached the end. +func (i *mergedIterator[Parent, Cache]) Valid() bool { + return i.valid } -// Close implements Iterator -func (iter *mergedIterator) Close() error { - err1 := iter.cache.Close() - if err := iter.parent.Close(); err != nil { - return err +// Next advances the iterator to the next valid item. +// It skips over deleted items (with nil values) and updates the current key and value. +func (i *mergedIterator[Parent, Cache]) Next() { + if !i.valid { + i.err = errors.New("invalid iterator") + return } - - return err1 + i.advance() } -var errInvalidIterator = errors.New("invalid merged iterator") - -// Error returns an error if the mergedIterator is invalid defined by the -// Valid method. -func (iter *mergedIterator) Error() error { - if !iter.Valid() { - return errInvalidIterator +// Key returns the current key pointed by the iterator. +// If the iterator is invalid, it returns nil. +func (i *mergedIterator[Parent, Cache]) Key() []byte { + if !i.valid { + return nil } - - return nil + return i.currKey } -// If not valid, panics. -// NOTE: May have side-effect of iterating over cache. -func (iter *mergedIterator) assertValid() { - if err := iter.Error(); err != nil { - panic(err) +// Value returns the current value corresponding to the current key. +// If the iterator is invalid, it returns nil. +func (i *mergedIterator[Parent, Cache]) Value() []byte { + if !i.valid { + return nil } + return i.currValue } -// Like bytes.Compare but opposite if not ascending. -func (iter *mergedIterator) compare(a, b []byte) int { - if iter.ascending { - return bytes.Compare(a, b) +// Close closes both the parent and cache iterators. +// It returns any error encountered during the closing of the iterators. +func (i *mergedIterator[Parent, Cache]) Close() error { + err1 := i.parent.Close() + err2 := i.cache.Close() + if err1 != nil { + return err1 } - - return bytes.Compare(a, b) * -1 + return err2 } -// Skip all delete-items from the cache w/ `key < until`. After this function, -// current cache item is a non-delete-item, or `until <= key`. -// If the current cache item is not a delete item, does nothing. -// If `until` is nil, there is no limit, and cache may end up invalid. -// CONTRACT: cache is valid. -func (iter *mergedIterator) skipCacheDeletes(until []byte) { - for iter.cache.Valid() && - iter.cache.Value() == nil && - (until == nil || iter.compare(iter.cache.Key(), until) < 0) { - iter.cache.Next() - } +// Error returns any error that occurred during iteration. +// If the iterator is valid, it returns nil. +func (i *mergedIterator[Parent, Cache]) Error() error { + return i.err } -// Fast forwards cache (or parent+cache in case of deleted items) until current -// item exists, or until iterator becomes invalid. -// Returns whether the iterator is valid. -func (iter *mergedIterator) skipUntilExistsOrInvalid() bool { +// advance moves the iterator to the next valid (non-deleted) item. +// It handles merging logic between the parent and cache iterators. +func (i *mergedIterator[Parent, Cache]) advance() { for { - // If parent is invalid, fast-forward cache. - if !iter.parent.Valid() { - iter.skipCacheDeletes(nil) - return iter.cache.Valid() + // Check if both iterators have reached the end + if !i.parent.Valid() && !i.cache.Valid() { + i.valid = false + return } - // Parent is valid. - if !iter.cache.Valid() { - return true + var key, value []byte + + // If parent iterator is exhausted, use the cache iterator + if !i.parent.Valid() { + key = i.cache.Key() + value = i.cache.Value() + i.cache.Next() + } else if !i.cache.Valid() { + // If cache iterator is exhausted, use the parent iterator + key = i.parent.Key() + value = i.parent.Value() + i.parent.Next() + } else { + // Both iterators are valid; compare keys + keyP, keyC := i.parent.Key(), i.cache.Key() + switch cmp := i.compare(keyP, keyC); { + case cmp < 0: + // Parent key is less than cache key + key = keyP + value = i.parent.Value() + i.parent.Next() + case cmp == 0: + // Keys are equal; cache overrides parent + key = keyC + value = i.cache.Value() + i.parent.Next() + i.cache.Next() + case cmp > 0: + // Cache key is less than parent key + key = keyC + value = i.cache.Value() + i.cache.Next() + } } - // Parent is valid, cache is valid. - - // Compare parent and cache. - keyP := iter.parent.Key() - keyC := iter.cache.Key() - switch iter.compare(keyP, keyC) { - case -1: // parent < cache. - return true + // Skip deleted items (value is nil) + if value == nil { + continue + } - case 0: // parent == cache. - // Skip over if cache item is a delete. - valueC := iter.cache.Value() - if valueC == nil { - iter.parent.Next() - iter.cache.Next() + // Update the current key and value, and mark iterator as valid + i.currKey = key + i.currValue = value + i.valid = true + return + } +} - continue - } - // Cache is not a delete. - - return true // cache exists. - case 1: // cache < parent - // Skip over if cache item is a delete. - valueC := iter.cache.Value() - if valueC == nil { - iter.skipCacheDeletes(keyP) - continue - } - // Cache is not a delete. - return true // cache exists. - } +// compare compares two byte slices a and b. +// It returns an integer comparing a and b: +// - Negative if a < b +// - Zero if a == b +// - Positive if a > b +// +// The comparison respects the iterator's direction (ascending or descending). +func (i *mergedIterator[Parent, Cache]) compare(a, b []byte) int { + if i.ascending { + return bytes.Compare(a, b) } + return bytes.Compare(b, a) } From ee40c11077d2c470332655a488719e648b81ebf2 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Fri, 4 Oct 2024 15:46:58 +0200 Subject: [PATCH 02/13] small tweak --- server/v2/stf/branch/mergeiter.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/v2/stf/branch/mergeiter.go b/server/v2/stf/branch/mergeiter.go index c35ed9ddbb30..e057643c09e3 100644 --- a/server/v2/stf/branch/mergeiter.go +++ b/server/v2/stf/branch/mergeiter.go @@ -7,6 +7,10 @@ import ( corestore "cosmossdk.io/core/store" ) +var ( + errInvalidIterator = errors.New("invalid iterator") +) + // mergedIterator merges a parent Iterator and a cache Iterator. // The cache iterator may contain items that shadow or override items in the parent iterator. // If the cache iterator has the same key as the parent, the cache's value takes precedence. @@ -52,7 +56,7 @@ func (i *mergedIterator[Parent, Cache]) Valid() bool { // It skips over deleted items (with nil values) and updates the current key and value. func (i *mergedIterator[Parent, Cache]) Next() { if !i.valid { - i.err = errors.New("invalid iterator") + i.err = errInvalidIterator return } i.advance() From b4b99fb7b1642918511107c8bec15d51db53724c Mon Sep 17 00:00:00 2001 From: testinginprod Date: Fri, 4 Oct 2024 15:50:36 +0200 Subject: [PATCH 03/13] small revert --- server/v2/stf/branch/changeset.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/v2/stf/branch/changeset.go b/server/v2/stf/branch/changeset.go index 8aac45f8953f..07a29345aee7 100644 --- a/server/v2/stf/branch/changeset.go +++ b/server/v2/stf/branch/changeset.go @@ -3,7 +3,6 @@ package branch import ( "bytes" "errors" - "fmt" "github.com/tidwall/btree" ) @@ -166,7 +165,7 @@ func (mi *memIterator) Close() error { // Otherwise, it returns nil. func (mi *memIterator) Error() error { if !mi.Valid() { - return fmt.Errorf("invalid iterator") + return errInvalidIterator } return nil } From af57f0d8cb5de5ea82f08fe9bedb977a01ff323d Mon Sep 17 00:00:00 2001 From: testinginprod Date: Tue, 8 Oct 2024 15:19:21 +0200 Subject: [PATCH 04/13] address PR reviews --- server/v2/stf/branch/mergeiter.go | 4 +-- server/v2/stf/branch/mergeiter_test.go | 46 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/server/v2/stf/branch/mergeiter.go b/server/v2/stf/branch/mergeiter.go index e057643c09e3..042d9d390b31 100644 --- a/server/v2/stf/branch/mergeiter.go +++ b/server/v2/stf/branch/mergeiter.go @@ -66,7 +66,7 @@ func (i *mergedIterator[Parent, Cache]) Next() { // If the iterator is invalid, it returns nil. func (i *mergedIterator[Parent, Cache]) Key() []byte { if !i.valid { - return nil + panic("called key on invalid iterator") } return i.currKey } @@ -75,7 +75,7 @@ func (i *mergedIterator[Parent, Cache]) Key() []byte { // If the iterator is invalid, it returns nil. func (i *mergedIterator[Parent, Cache]) Value() []byte { if !i.valid { - return nil + panic("called value on invalid iterator") } return i.currValue } diff --git a/server/v2/stf/branch/mergeiter_test.go b/server/v2/stf/branch/mergeiter_test.go index 1a9e13bbe65c..45f10d4c1b36 100644 --- a/server/v2/stf/branch/mergeiter_test.go +++ b/server/v2/stf/branch/mergeiter_test.go @@ -7,6 +7,52 @@ import ( corestore "cosmossdk.io/core/store" ) +func TestMergedIterator_Validity(t *testing.T) { + panics := func(f func()) { + defer func() { + r := recover() + if r == nil { + t.Error("panic expected") + } + }() + + f() + } + + t.Run("panics when calling key on invalid iter", func(t *testing.T) { + parent, err := newMemState().Iterator(nil, nil) + if err != nil { + t.Fatal(err) + } + cache, err := newMemState().Iterator(nil, nil) + if err != nil { + t.Fatal(err) + } + + it := mergeIterators(parent, cache, true) + panics(func() { + it.Key() + }) + }) + + t.Run("panics when calling value on invalid iter", func(t *testing.T) { + parent, err := newMemState().Iterator(nil, nil) + if err != nil { + t.Fatal(err) + } + cache, err := newMemState().Iterator(nil, nil) + if err != nil { + t.Fatal(err) + } + + it := mergeIterators(parent, cache, true) + + panics(func() { + it.Value() + }) + }) +} + func TestMergedIterator_Next(t *testing.T) { specs := map[string]struct { setup func() corestore.Iterator From f5110c966fa7d0c872448cea4d8d6d4de2c2fba8 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Tue, 8 Oct 2024 15:21:43 +0200 Subject: [PATCH 05/13] address PR reviews 2 --- server/v2/stf/branch/mergeiter.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server/v2/stf/branch/mergeiter.go b/server/v2/stf/branch/mergeiter.go index 042d9d390b31..108d19e7e041 100644 --- a/server/v2/stf/branch/mergeiter.go +++ b/server/v2/stf/branch/mergeiter.go @@ -82,13 +82,11 @@ func (i *mergedIterator[Parent, Cache]) Value() []byte { // Close closes both the parent and cache iterators. // It returns any error encountered during the closing of the iterators. -func (i *mergedIterator[Parent, Cache]) Close() error { - err1 := i.parent.Close() - err2 := i.cache.Close() - if err1 != nil { - return err1 - } - return err2 +func (i *mergedIterator[Parent, Cache]) Close() (err error) { + err = errors.Join(err, i.parent.Close()) + err = errors.Join(err, i.cache.Close()) + i.valid = false + return err } // Error returns any error that occurred during iteration. From d4c27a26719e91bfbc484b423d9b4c705919f7e8 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Tue, 29 Oct 2024 16:24:15 +0100 Subject: [PATCH 06/13] add benches --- server/v2/stf/branch/bench_test.go | 172 +++++++++++++++++++++++++++++ server/v2/stf/go.mod | 7 +- server/v2/stf/go.sum | 2 + 3 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 server/v2/stf/branch/bench_test.go diff --git a/server/v2/stf/branch/bench_test.go b/server/v2/stf/branch/bench_test.go new file mode 100644 index 000000000000..2e0097ba6535 --- /dev/null +++ b/server/v2/stf/branch/bench_test.go @@ -0,0 +1,172 @@ +package branch + +import ( + "testing" + + "cosmossdk.io/core/store" + coretesting "cosmossdk.io/core/testing" +) + +func Benchmark_CacheStack1_Set(b *testing.B) { + bs := makeBranchStack(b, 1) + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + err := bs.Set([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + } +} + +func Benchmark_CacheStack10_Set(b *testing.B) { + bs := makeBranchStack(b, 10) + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + err := bs.Set([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + } +} + +func Benchmark_CacheStack100_Set(b *testing.B) { + bs := makeBranchStack(b, 100) + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + err := bs.Set([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + } +} + +func Benchmark_CacheStack1_Get(b *testing.B) { + bs := makeBranchStack(b, 1) + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + _, err := bs.Get([]byte{0}) + if err != nil { + b.Fatal(err) + } + } +} + +func Benchmark_CacheStack10_Get(b *testing.B) { + bs := makeBranchStack(b, 10) + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + _, err := bs.Get([]byte{0}) + if err != nil { + b.Fatal(err) + } + } +} + +func Benchmark_CacheStack100_Get(b *testing.B) { + bs := makeBranchStack(b, 100) + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + _, err := bs.Get([]byte{0}) + if err != nil { + b.Fatal(err) + } + } +} + +func Benchmark_CacheStack1_Iterate(b *testing.B) { + bs := makeBranchStack(b, 1) + var keySink, valueSink any + + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + iter, err := bs.Iterator([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + for iter.Valid() { + iter.Next() + keySink = iter.Key() + valueSink = iter.Value() + } + } + + _ = keySink + _ = valueSink +} + +func Benchmark_CacheStack10_Iterate(b *testing.B) { + bs := makeBranchStack(b, 10) + var keySink, valueSink any + + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + iter, err := bs.Iterator([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + for iter.Valid() { + iter.Next() + keySink = iter.Key() + valueSink = iter.Value() + } + } + + _ = keySink + _ = valueSink +} + +func Benchmark_CacheStack100_Iterate(b *testing.B) { + bs := makeBranchStack(b, 100) + var keySink, valueSink any + + b.ResetTimer() + b.ReportAllocs() + // test sets + for i := 0; i < b.N; i++ { + iter, err := bs.Iterator([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + for iter.Valid() { + iter.Next() + keySink = iter.Key() + valueSink = iter.Value() + } + } + + _ = keySink + _ = valueSink +} + +func makeBranchStack(b *testing.B, stackSize int) Store[store.KVStore] { + const elems = 10 + parent := coretesting.NewMemKV() + branch := NewStore[store.KVStore](parent) + for i := 1; i < stackSize; i++ { + branch = NewStore[store.KVStore](branch) + for j := 0; j < elems; j++ { + key, value := []byte{byte(j)}, []byte{byte(j)} + err := branch.Set(key, value) + if err != nil { + b.Fatal(err) + } + } + } + return branch +} diff --git a/server/v2/stf/go.mod b/server/v2/stf/go.mod index 7f55feb3f3f2..c8f18d0bbe04 100644 --- a/server/v2/stf/go.mod +++ b/server/v2/stf/go.mod @@ -3,7 +3,8 @@ module cosmossdk.io/server/v2/stf go 1.23 require ( - cosmossdk.io/core v1.0.0-alpha.4 + cosmossdk.io/core v1.0.0-alpha.5 + cosmossdk.io/core/testing v0.0.0 cosmossdk.io/schema v0.3.0 github.com/cosmos/gogoproto v1.7.0 github.com/tidwall/btree v1.7.0 @@ -13,3 +14,7 @@ require ( github.com/google/go-cmp v0.6.0 // indirect google.golang.org/protobuf v1.35.1 // indirect ) + +replace ( + cosmossdk.io/core/testing => ../../../core/testing +) diff --git a/server/v2/stf/go.sum b/server/v2/stf/go.sum index 29d26cc868dc..3813c60a7c9d 100644 --- a/server/v2/stf/go.sum +++ b/server/v2/stf/go.sum @@ -1,5 +1,7 @@ cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY= cosmossdk.io/core v1.0.0-alpha.4/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY= +cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI= +cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY= cosmossdk.io/schema v0.3.0 h1:01lcaM4trhzZ1HQTfTV8z6Ma1GziOZ/YmdzBN3F720c= cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ= github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro= From 40d491e4546285cffe87e77c88c7e3f26ff576a0 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Thu, 31 Oct 2024 11:58:41 +0100 Subject: [PATCH 07/13] more refactors --- server/v2/stf/branch/bench_test.go | 189 +++++++++-------------------- 1 file changed, 54 insertions(+), 135 deletions(-) diff --git a/server/v2/stf/branch/bench_test.go b/server/v2/stf/branch/bench_test.go index 2e0097ba6535..ff0286517d55 100644 --- a/server/v2/stf/branch/bench_test.go +++ b/server/v2/stf/branch/bench_test.go @@ -1,167 +1,86 @@ package branch import ( + "fmt" "testing" "cosmossdk.io/core/store" coretesting "cosmossdk.io/core/testing" ) -func Benchmark_CacheStack1_Set(b *testing.B) { - bs := makeBranchStack(b, 1) - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - err := bs.Set([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } - } -} - -func Benchmark_CacheStack10_Set(b *testing.B) { - bs := makeBranchStack(b, 10) - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - err := bs.Set([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } - } -} - -func Benchmark_CacheStack100_Set(b *testing.B) { - bs := makeBranchStack(b, 100) - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - err := bs.Set([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } - } -} - -func Benchmark_CacheStack1_Get(b *testing.B) { - bs := makeBranchStack(b, 1) - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - _, err := bs.Get([]byte{0}) - if err != nil { - b.Fatal(err) - } - } -} - -func Benchmark_CacheStack10_Get(b *testing.B) { - bs := makeBranchStack(b, 10) - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - _, err := bs.Get([]byte{0}) - if err != nil { - b.Fatal(err) - } - } -} - -func Benchmark_CacheStack100_Get(b *testing.B) { - bs := makeBranchStack(b, 100) - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - _, err := bs.Get([]byte{0}) - if err != nil { - b.Fatal(err) - } - } -} - -func Benchmark_CacheStack1_Iterate(b *testing.B) { - bs := makeBranchStack(b, 1) - var keySink, valueSink any +var ( + stackSizes = []int{1, 10, 100} + elemsInStack = 10 +) - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - iter, err := bs.Iterator([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } - for iter.Valid() { - iter.Next() - keySink = iter.Key() - valueSink = iter.Value() - } +func Benchmark_CacheStack_Set(b *testing.B) { + for _, stackSize := range stackSizes { + b.Run(fmt.Sprintf("StackSize%d", stackSize), func(b *testing.B) { + bs := makeBranchStack(b, stackSize) + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + err := bs.Set([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + } + }) } - - _ = keySink - _ = valueSink } -func Benchmark_CacheStack10_Iterate(b *testing.B) { - bs := makeBranchStack(b, 10) - var keySink, valueSink any - - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - iter, err := bs.Iterator([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } - for iter.Valid() { - iter.Next() - keySink = iter.Key() - valueSink = iter.Value() - } +func Benchmark_Get(b *testing.B) { + for _, stackSize := range stackSizes { + b.Run(fmt.Sprintf("StackSize%d", stackSize), func(b *testing.B) { + bs := makeBranchStack(b, stackSize) + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _, err := bs.Get([]byte{0}) + if err != nil { + b.Fatal(err) + } + } + }) } - - _ = keySink - _ = valueSink } -func Benchmark_CacheStack100_Iterate(b *testing.B) { - bs := makeBranchStack(b, 100) +func Benchmark_Iterate(b *testing.B) { var keySink, valueSink any - b.ResetTimer() - b.ReportAllocs() - // test sets - for i := 0; i < b.N; i++ { - iter, err := bs.Iterator([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } - for iter.Valid() { - iter.Next() - keySink = iter.Key() - valueSink = iter.Value() - } + for _, stackSize := range stackSizes { + b.Run(fmt.Sprintf("StackSize%d", stackSize), func(b *testing.B) { + bs := makeBranchStack(b, stackSize) + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + iter, err := bs.Iterator([]byte{0}, []byte{0}) + if err != nil { + b.Fatal(err) + } + for iter.Valid() { + iter.Next() + keySink = iter.Key() + valueSink = iter.Value() + } + } + }) } _ = keySink _ = valueSink } +// makeBranchStack creates a branch stack of the given size and initializes it with unique key-value pairs. func makeBranchStack(b *testing.B, stackSize int) Store[store.KVStore] { - const elems = 10 parent := coretesting.NewMemKV() branch := NewStore[store.KVStore](parent) for i := 1; i < stackSize; i++ { branch = NewStore[store.KVStore](branch) - for j := 0; j < elems; j++ { - key, value := []byte{byte(j)}, []byte{byte(j)} + for j := 0; j < elemsInStack; j++ { + // create unique keys by including the branch index. + key := []byte{byte(i), byte(j)} + value := []byte{byte(j)} err := branch.Set(key, value) if err != nil { b.Fatal(err) From 1b683c8da952f18b6c689340b2ebb61e3780e08d Mon Sep 17 00:00:00 2001 From: testinginprod Date: Thu, 31 Oct 2024 12:12:13 +0100 Subject: [PATCH 08/13] also add iter closing --- server/v2/stf/branch/bench_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/v2/stf/branch/bench_test.go b/server/v2/stf/branch/bench_test.go index ff0286517d55..0e24cc8cbf1d 100644 --- a/server/v2/stf/branch/bench_test.go +++ b/server/v2/stf/branch/bench_test.go @@ -63,6 +63,10 @@ func Benchmark_Iterate(b *testing.B) { keySink = iter.Key() valueSink = iter.Value() } + err = iter.Close() + if err != nil { + b.Fatal(err) + } } }) } From 5559b34c1d50d7176fc0663ed74089230a2999c2 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Thu, 31 Oct 2024 12:42:43 +0100 Subject: [PATCH 09/13] checkpoint --- server/v2/stf/branch/bench_test.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/server/v2/stf/branch/bench_test.go b/server/v2/stf/branch/bench_test.go index 0e24cc8cbf1d..db46846c1677 100644 --- a/server/v2/stf/branch/bench_test.go +++ b/server/v2/stf/branch/bench_test.go @@ -20,10 +20,7 @@ func Benchmark_CacheStack_Set(b *testing.B) { b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - err := bs.Set([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } + _ = bs.Set([]byte{0}, []byte{0}) } }) } @@ -36,10 +33,7 @@ func Benchmark_Get(b *testing.B) { b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - _, err := bs.Get([]byte{0}) - if err != nil { - b.Fatal(err) - } + _, _ = bs.Get([]byte{0}) } }) } @@ -54,19 +48,13 @@ func Benchmark_Iterate(b *testing.B) { b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - iter, err := bs.Iterator([]byte{0}, []byte{0}) - if err != nil { - b.Fatal(err) - } + iter, _ := bs.Iterator(nil, nil) for iter.Valid() { - iter.Next() keySink = iter.Key() valueSink = iter.Value() + iter.Next() } - err = iter.Close() - if err != nil { - b.Fatal(err) - } + _ = iter.Close() } }) } From 43a1cf7e26afc2d4855d0a5e11721f7ed99cad82 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Fri, 1 Nov 2024 15:00:50 +0100 Subject: [PATCH 10/13] checkpoint --- server/v2/stf/branch/cache.go | 28 ++++++++++ server/v2/stf/branch/changeset.go | 2 +- server/v2/stf/branch/mergeiter.go | 74 +++++++++++++------------- server/v2/stf/branch/mergeiter_test.go | 16 +++--- server/v2/stf/branch/store.go | 27 +++++++--- 5 files changed, 94 insertions(+), 53 deletions(-) create mode 100644 server/v2/stf/branch/cache.go diff --git a/server/v2/stf/branch/cache.go b/server/v2/stf/branch/cache.go new file mode 100644 index 000000000000..81302c1c941f --- /dev/null +++ b/server/v2/stf/branch/cache.go @@ -0,0 +1,28 @@ +package branch + +import "unsafe" + +func newMemoryCache() memoryCache { + return memoryCache{ + items: map[string][]byte{}, + } +} + +type memoryCache struct { + items map[string][]byte +} + +func (l memoryCache) get(key []byte) (value []byte, found bool) { + keyStr := unsafe.String(unsafe.SliceData(key), len(key)) + + value, found = l.items[keyStr] + return +} + +func (l memoryCache) set(key, value []byte) { + l.items[string(key)] = value +} + +func (l memoryCache) delete(key []byte) { + l.items[string(key)] = nil +} diff --git a/server/v2/stf/branch/changeset.go b/server/v2/stf/branch/changeset.go index 07a29345aee7..a5f168a515dd 100644 --- a/server/v2/stf/branch/changeset.go +++ b/server/v2/stf/branch/changeset.go @@ -15,7 +15,7 @@ const ( var errKeyEmpty = errors.New("key cannot be empty") -// changeSet implements the sorted cache for cachekv store, +// changeSet implements the sorted tree for cachekv store, // we don't use MemDB here because cachekv is used extensively in sdk core path, // we need it to be as fast as possible, while `MemDB` is mainly used as a mocking db in unit tests. // diff --git a/server/v2/stf/branch/mergeiter.go b/server/v2/stf/branch/mergeiter.go index 108d19e7e041..58d237c09920 100644 --- a/server/v2/stf/branch/mergeiter.go +++ b/server/v2/stf/branch/mergeiter.go @@ -11,13 +11,13 @@ var ( errInvalidIterator = errors.New("invalid iterator") ) -// mergedIterator merges a parent Iterator and a cache Iterator. -// The cache iterator may contain items that shadow or override items in the parent iterator. -// If the cache iterator has the same key as the parent, the cache's value takes precedence. -// Deleted items in the cache (indicated by nil values) are skipped. -type mergedIterator[Parent, Cache corestore.Iterator] struct { +// mergedIterator merges a parent Iterator and a child Iterator. +// The child iterator may contain items that shadow or override items in the parent iterator. +// If the child iterator has the same key as the parent, the child's value takes precedence. +// Deleted items in the child (indicated by nil values) are skipped. +type mergedIterator[Parent, Child corestore.Iterator] struct { parent Parent // Iterator for the parent store - cache Cache // Iterator for the cache store + child Child // Iterator for the child store ascending bool // Direction of iteration valid bool // Indicates if the iterator is in a valid state currKey []byte // Current key pointed by the iterator @@ -28,12 +28,12 @@ type mergedIterator[Parent, Cache corestore.Iterator] struct { // Ensure mergedIterator implements the corestore.Iterator interface. var _ corestore.Iterator = (*mergedIterator[corestore.Iterator, corestore.Iterator])(nil) -// mergeIterators creates a new merged iterator from parent and cache iterators. +// mergeIterators creates a new merged iterator from parent and child iterators. // The 'ascending' parameter determines the direction of iteration. -func mergeIterators[Parent, Cache corestore.Iterator](parent Parent, cache Cache, ascending bool) *mergedIterator[Parent, Cache] { - iter := &mergedIterator[Parent, Cache]{ +func mergeIterators[Parent, Child corestore.Iterator](parent Parent, child Child, ascending bool) *mergedIterator[Parent, Child] { + iter := &mergedIterator[Parent, Child]{ parent: parent, - cache: cache, + child: child, ascending: ascending, } iter.advance() // Initialize the iterator by advancing to the first valid item @@ -42,19 +42,19 @@ func mergeIterators[Parent, Cache corestore.Iterator](parent Parent, cache Cache // Domain returns the start and end range of the iterator. // It delegates to the parent iterator as both iterators share the same domain. -func (i *mergedIterator[Parent, Cache]) Domain() (start, end []byte) { +func (i *mergedIterator[Parent, Child]) Domain() (start, end []byte) { return i.parent.Domain() } // Valid checks if the iterator is in a valid state. // It returns true if the iterator has not reached the end. -func (i *mergedIterator[Parent, Cache]) Valid() bool { +func (i *mergedIterator[Parent, Child]) Valid() bool { return i.valid } // Next advances the iterator to the next valid item. // It skips over deleted items (with nil values) and updates the current key and value. -func (i *mergedIterator[Parent, Cache]) Next() { +func (i *mergedIterator[Parent, Child]) Next() { if !i.valid { i.err = errInvalidIterator return @@ -64,7 +64,7 @@ func (i *mergedIterator[Parent, Cache]) Next() { // Key returns the current key pointed by the iterator. // If the iterator is invalid, it returns nil. -func (i *mergedIterator[Parent, Cache]) Key() []byte { +func (i *mergedIterator[Parent, Child]) Key() []byte { if !i.valid { panic("called key on invalid iterator") } @@ -73,70 +73,70 @@ func (i *mergedIterator[Parent, Cache]) Key() []byte { // Value returns the current value corresponding to the current key. // If the iterator is invalid, it returns nil. -func (i *mergedIterator[Parent, Cache]) Value() []byte { +func (i *mergedIterator[Parent, Child]) Value() []byte { if !i.valid { panic("called value on invalid iterator") } return i.currValue } -// Close closes both the parent and cache iterators. +// Close closes both the parent and child iterators. // It returns any error encountered during the closing of the iterators. -func (i *mergedIterator[Parent, Cache]) Close() (err error) { +func (i *mergedIterator[Parent, Child]) Close() (err error) { err = errors.Join(err, i.parent.Close()) - err = errors.Join(err, i.cache.Close()) + err = errors.Join(err, i.child.Close()) i.valid = false return err } // Error returns any error that occurred during iteration. // If the iterator is valid, it returns nil. -func (i *mergedIterator[Parent, Cache]) Error() error { +func (i *mergedIterator[Parent, Child]) Error() error { return i.err } // advance moves the iterator to the next valid (non-deleted) item. -// It handles merging logic between the parent and cache iterators. -func (i *mergedIterator[Parent, Cache]) advance() { +// It handles merging logic between the parent and child iterators. +func (i *mergedIterator[Parent, Child]) advance() { for { // Check if both iterators have reached the end - if !i.parent.Valid() && !i.cache.Valid() { + if !i.parent.Valid() && !i.child.Valid() { i.valid = false return } var key, value []byte - // If parent iterator is exhausted, use the cache iterator + // If parent iterator is exhausted, use the child iterator if !i.parent.Valid() { - key = i.cache.Key() - value = i.cache.Value() - i.cache.Next() - } else if !i.cache.Valid() { - // If cache iterator is exhausted, use the parent iterator + key = i.child.Key() + value = i.child.Value() + i.child.Next() + } else if !i.child.Valid() { + // If child iterator is exhausted, use the parent iterator key = i.parent.Key() value = i.parent.Value() i.parent.Next() } else { // Both iterators are valid; compare keys - keyP, keyC := i.parent.Key(), i.cache.Key() + keyP, keyC := i.parent.Key(), i.child.Key() switch cmp := i.compare(keyP, keyC); { case cmp < 0: - // Parent key is less than cache key + // Parent key is less than child key key = keyP value = i.parent.Value() i.parent.Next() case cmp == 0: - // Keys are equal; cache overrides parent + // Keys are equal; child overrides parent key = keyC - value = i.cache.Value() + value = i.child.Value() i.parent.Next() - i.cache.Next() + i.child.Next() case cmp > 0: - // Cache key is less than parent key + // Child key is less than parent key key = keyC - value = i.cache.Value() - i.cache.Next() + value = i.child.Value() + i.child.Next() } } @@ -160,7 +160,7 @@ func (i *mergedIterator[Parent, Cache]) advance() { // - Positive if a > b // // The comparison respects the iterator's direction (ascending or descending). -func (i *mergedIterator[Parent, Cache]) compare(a, b []byte) int { +func (i *mergedIterator[Parent, Child]) compare(a, b []byte) int { if i.ascending { return bytes.Compare(a, b) } diff --git a/server/v2/stf/branch/mergeiter_test.go b/server/v2/stf/branch/mergeiter_test.go index 45f10d4c1b36..1b7253f8112e 100644 --- a/server/v2/stf/branch/mergeiter_test.go +++ b/server/v2/stf/branch/mergeiter_test.go @@ -65,7 +65,7 @@ func TestMergedIterator_Next(t *testing.T) { return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true) }, }, - "parent iterator has one item, cache is empty": { + "parent iterator has one item, child is empty": { setup: func() corestore.Iterator { parent := newMemState() if err := parent.Set([]byte("k1"), []byte("1")); err != nil { @@ -76,7 +76,7 @@ func TestMergedIterator_Next(t *testing.T) { }, exp: [][2]string{{"k1", "1"}}, }, - "cache has one item, parent is empty": { + "child has one item, parent is empty": { setup: func() corestore.Iterator { parent := newMemState() cache := newMemState() @@ -87,21 +87,21 @@ func TestMergedIterator_Next(t *testing.T) { }, exp: [][2]string{{"k1", "1"}}, }, - "both iterators have same key, cache preferred": { + "both iterators have same key, child preferred": { setup: func() corestore.Iterator { parent := newMemState() if err := parent.Set([]byte("k1"), []byte("parent-val")); err != nil { t.Fatal(err) } cache := newMemState() - if err := cache.Set([]byte("k1"), []byte("cache-val")); err != nil { + if err := cache.Set([]byte("k1"), []byte("child-val")); err != nil { t.Fatal(err) } return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true) }, - exp: [][2]string{{"k1", "cache-val"}}, + exp: [][2]string{{"k1", "child-val"}}, }, - "both iterators have same key, but cache value is nil": { + "both iterators have same key, but child value is nil": { setup: func() corestore.Iterator { parent := newMemState() if err := parent.Set([]byte("k1"), []byte("1")); err != nil { @@ -114,7 +114,7 @@ func TestMergedIterator_Next(t *testing.T) { return mergeIterators(must(parent.Iterator(nil, nil)), must(cache.Iterator(nil, nil)), true) }, }, - "parent and cache are ascending": { + "parent and child are ascending": { setup: func() corestore.Iterator { parent := newMemState() if err := parent.Set([]byte("k2"), []byte("v2")); err != nil { @@ -134,7 +134,7 @@ func TestMergedIterator_Next(t *testing.T) { }, exp: [][2]string{{"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}, {"k4", "v4"}}, }, - "parent and cache are descending": { + "parent and child are descending": { setup: func() corestore.Iterator { parent := newMemState() if err := parent.Set([]byte("k3"), []byte("v3")); err != nil { diff --git a/server/v2/stf/branch/store.go b/server/v2/stf/branch/store.go index f0d6d0b3a1ea..a9caa0177a0b 100644 --- a/server/v2/stf/branch/store.go +++ b/server/v2/stf/branch/store.go @@ -8,27 +8,37 @@ import ( var _ store.Writer = (*Store[store.Reader])(nil) -// Store wraps an in-memory cache around an underlying types.KVStore. +// Store wraps an in-memory child around an underlying types.KVStore. type Store[T store.Reader] struct { - changeSet changeSet // always ascending sorted - parent T + changeSet changeSet // ordered changeset. + memoryCache memoryCache // fast lookup map for changeset, unordered. + parent T } // NewStore creates a new Store object func NewStore[T store.Reader](parent T) Store[T] { return Store[T]{ - changeSet: newChangeSet(), - parent: parent, + changeSet: newChangeSet(), + memoryCache: newMemoryCache(), + parent: parent, } } // Get implements types.KVStore. func (s Store[T]) Get(key []byte) (value []byte, err error) { - value, found := s.changeSet.get(key) + // if found in memory cache, immediately return. + value, found := s.memoryCache.get(key) if found { return } - return s.parent.Get(key) + // after we get it from parent store, we cache it. + // if it is not found in parent store, we still cache it as nil. + value, err = s.parent.Get(key) + if err != nil { + return nil, err + } + s.memoryCache.set(key, value) + return value, nil } // Set implements types.KVStore. @@ -38,6 +48,8 @@ func (s Store[T]) Set(key, value []byte) error { } s.changeSet.set(key, value) + s.memoryCache.set(key, value) + return nil } @@ -53,6 +65,7 @@ func (s Store[T]) Has(key []byte) (bool, error) { // Delete implements types.KVStore. func (s Store[T]) Delete(key []byte) error { s.changeSet.delete(key) + s.memoryCache.delete(key) return nil } From 80bba0e41751e7657fcf536f556138b4d5765324 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Tue, 5 Nov 2024 15:06:36 +0100 Subject: [PATCH 11/13] go.mod tidy --- runtime/v2/go.mod | 3 ++- runtime/v2/go.sum | 2 -- server/v2/cometbft/go.mod | 3 ++- server/v2/cometbft/go.sum | 2 -- server/v2/stf/go.mod | 4 +--- simapp/v2/go.mod | 3 ++- simapp/v2/go.sum | 2 -- 7 files changed, 7 insertions(+), 12 deletions(-) diff --git a/runtime/v2/go.mod b/runtime/v2/go.mod index 78ad2b0fe974..a9640d516a58 100644 --- a/runtime/v2/go.mod +++ b/runtime/v2/go.mod @@ -5,6 +5,7 @@ go 1.23 // server v2 integration replace ( cosmossdk.io/api => ../../api + cosmossdk.io/core/testing => ../../core/testing cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager cosmossdk.io/server/v2/stf => ../../server/v2/stf cosmossdk.io/store/v2 => ../../store/v2 @@ -30,7 +31,7 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect - cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect + cosmossdk.io/core/testing v0.0.0 // indirect cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/runtime/v2/go.sum b/runtime/v2/go.sum index cdf94ffd213b..afb28ea22908 100644 --- a/runtime/v2/go.sum +++ b/runtime/v2/go.sum @@ -4,8 +4,6 @@ buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88e buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1/go.mod h1:zqi/LZjZhyvjCMTEVIwAf5VRlkLduuCfqmZxgoormq0= cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI= cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs= cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 h1:IQNdY2kB+k+1OM2DvqFG1+UgeU1JzZrWtwuWzI3ZfwA= diff --git a/server/v2/cometbft/go.mod b/server/v2/cometbft/go.mod index e582690cd789..bb2ccd46f133 100644 --- a/server/v2/cometbft/go.mod +++ b/server/v2/cometbft/go.mod @@ -4,6 +4,7 @@ go 1.23.1 replace ( cosmossdk.io/api => ../../../api + cosmossdk.io/core/testing => ../../../core/testing cosmossdk.io/server/v2 => ../ cosmossdk.io/server/v2/appmanager => ../appmanager cosmossdk.io/server/v2/stf => ../stf @@ -43,7 +44,7 @@ require ( require ( buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect - cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect + cosmossdk.io/core/testing v0.0.0 // indirect cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/math v1.3.0 // indirect diff --git a/server/v2/cometbft/go.sum b/server/v2/cometbft/go.sum index 0fcabe91037e..793bde3f2c1d 100644 --- a/server/v2/cometbft/go.sum +++ b/server/v2/cometbft/go.sum @@ -8,8 +8,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI= cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs= cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= diff --git a/server/v2/stf/go.mod b/server/v2/stf/go.mod index c8f18d0bbe04..527eb2671cf0 100644 --- a/server/v2/stf/go.mod +++ b/server/v2/stf/go.mod @@ -15,6 +15,4 @@ require ( google.golang.org/protobuf v1.35.1 // indirect ) -replace ( - cosmossdk.io/core/testing => ../../../core/testing -) +replace cosmossdk.io/core/testing => ../../../core/testing diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod index 0e803ed0f86d..5ddba7bd2cfa 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -58,7 +58,7 @@ require ( cloud.google.com/go/iam v1.1.13 // indirect cloud.google.com/go/storage v1.43.0 // indirect cosmossdk.io/collections v0.4.0 // indirect - cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 // indirect + cosmossdk.io/core/testing v0.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5 // indirect cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect @@ -291,6 +291,7 @@ replace ( // server v2 integration replace ( cosmossdk.io/api => ../../api + cosmossdk.io/core/testing => ../../core/testing cosmossdk.io/runtime/v2 => ../../runtime/v2 cosmossdk.io/server/v2 => ../../server/v2 cosmossdk.io/server/v2/appmanager => ../../server/v2/appmanager diff --git a/simapp/v2/go.sum b/simapp/v2/go.sum index beee381cb4ec..1c8c11987fd9 100644 --- a/simapp/v2/go.sum +++ b/simapp/v2/go.sum @@ -194,8 +194,6 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= cosmossdk.io/core v1.0.0-alpha.5 h1:McjYXAQ6XcT20v2uHyH7PhoWH8V+mebzfVFqT3GinsI= cosmossdk.io/core v1.0.0-alpha.5/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29 h1:NxxUo0GMJUbIuVg0R70e3cbn9eFTEuMr7ev1AFvypdY= -cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29/go.mod h1:8s2tPeJtSiQuoyPmr2Ag7meikonISO4Fv4MoO8+ORrs= cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050= cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= From 8a59c4b427d942df783d09d2f1fb46d813f9b2e8 Mon Sep 17 00:00:00 2001 From: testinginprod Date: Tue, 5 Nov 2024 15:14:00 +0100 Subject: [PATCH 12/13] finalize benches and remove enhances --- server/v2/stf/branch/bench_22131.txt | 96 ++++++++++++++++++++++++++ server/v2/stf/branch/bench_storev1.txt | 96 ++++++++++++++++++++++++++ server/v2/stf/branch/cache.go | 28 -------- server/v2/stf/branch/store.go | 17 ++--- 4 files changed, 197 insertions(+), 40 deletions(-) create mode 100644 server/v2/stf/branch/bench_22131.txt create mode 100644 server/v2/stf/branch/bench_storev1.txt delete mode 100644 server/v2/stf/branch/cache.go diff --git a/server/v2/stf/branch/bench_22131.txt b/server/v2/stf/branch/bench_22131.txt new file mode 100644 index 000000000000..1a169ed7efb5 --- /dev/null +++ b/server/v2/stf/branch/bench_22131.txt @@ -0,0 +1,96 @@ +goos: darwin +goarch: arm64 +pkg: cosmossdk.io/server/v2/stf/branch +cpu: Apple M3 Max +Benchmark_CacheStack_Set/StackSize1-14 36413290 33.31 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 35942940 34.33 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 36227097 32.59 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 36985620 32.62 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 34493827 32.62 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 37298065 32.46 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 37051664 32.55 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 36883686 32.48 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 37034179 32.59 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 36960226 32.46 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 26045575 46.27 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 25950037 46.15 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 26205926 46.01 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 25982696 46.00 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 26053021 46.06 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 25772341 46.08 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 25855080 46.17 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 26162884 46.08 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 26146875 46.11 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 25878520 45.99 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 26067688 46.20 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 26085656 46.02 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 26131170 46.01 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 26144407 46.06 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 26018938 46.02 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 25682228 48.46 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 26095701 46.54 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 26147968 48.50 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 25609377 46.66 ns/op 2 B/op 2 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 25418208 46.67 ns/op 2 B/op 2 allocs/op +Benchmark_Get/StackSize1-14 47967780 24.95 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 47577195 25.19 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 47781637 24.94 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 47332609 25.00 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 47787187 25.03 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 48496687 24.83 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 48153289 24.89 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 48453279 24.69 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 48500605 24.71 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 48790486 24.77 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3676309 328.9 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3665226 327.0 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3669343 327.1 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3674840 327.2 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3667174 327.1 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3665042 327.0 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3666630 327.0 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3665234 327.5 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3680134 326.8 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 3663696 326.7 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 237254 5028 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 240108 5267 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 242304 5014 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 236968 5136 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 246918 5086 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 240165 4959 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 242150 5030 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 245880 4891 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 236239 5019 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 239452 5012 ns/op 1 B/op 1 allocs/op +Benchmark_Iterate/StackSize1-14 4859352 248.2 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4786867 250.3 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4754394 250.2 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4808739 249.5 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4803613 249.8 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4794133 250.9 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4799314 249.4 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4784235 252.0 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4848817 251.2 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize1-14 4752552 251.1 ns/op 984 B/op 7 allocs/op +Benchmark_Iterate/StackSize10-14 91701 13156 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 91626 13236 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 91365 14143 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 83239 13882 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 88155 13691 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 84646 13487 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 89509 13241 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 91993 13247 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 90870 13235 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize10-14 89091 13219 ns/op 10848 B/op 232 allocs/op +Benchmark_Iterate/StackSize100-14 831 1437972 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 831 1442003 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 830 1440507 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 832 1438528 ns/op 109494 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 836 1439228 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 828 1444444 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 836 1437128 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 836 1437714 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 834 1441704 ns/op 109488 B/op 2482 allocs/op +Benchmark_Iterate/StackSize100-14 832 1447616 ns/op 109488 B/op 2482 allocs/op +PASS +ok cosmossdk.io/server/v2/stf/branch 120.114s diff --git a/server/v2/stf/branch/bench_storev1.txt b/server/v2/stf/branch/bench_storev1.txt new file mode 100644 index 000000000000..14d7c5cedfb1 --- /dev/null +++ b/server/v2/stf/branch/bench_storev1.txt @@ -0,0 +1,96 @@ +goos: darwin +goarch: arm64 +pkg: cosmossdk.io/store/cachekv +cpu: Apple M3 Max +Benchmark_CacheStack_Set/StackSize1-14 23762670 50.66 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23815470 52.51 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23700504 50.09 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23894227 50.60 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23923881 51.59 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23567246 50.72 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23912976 50.76 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23585929 51.69 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 23619915 51.00 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize1-14 22026919 50.65 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 20656384 59.33 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 20070175 59.69 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 17762174 60.18 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 20686652 58.29 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 20080363 58.92 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 21156355 59.50 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 20363948 60.83 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 20779700 58.36 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 17666738 58.08 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize10-14 20784408 59.87 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 20917387 57.43 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 19810956 58.39 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 19317696 58.77 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 19808176 65.74 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 20627594 59.53 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 20669712 58.38 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 20143410 57.45 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 20125293 60.01 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 21023170 57.92 ns/op 34 B/op 3 allocs/op +Benchmark_CacheStack_Set/StackSize100-14 21142921 62.84 ns/op 34 B/op 3 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.63 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 99004795 11.54 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.58 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.67 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.57 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.47 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.88 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 99394999 11.60 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.65 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize1-14 100000000 11.94 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 71410506 17.11 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 71044978 17.04 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 73479136 16.02 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 73639016 16.63 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 72728744 16.38 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 71737082 16.13 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 76073544 15.72 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 73673114 15.55 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 70475266 16.27 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize10-14 76181808 16.57 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 69400598 18.96 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 73939244 16.36 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 71737443 15.75 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 71800394 16.43 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 72954243 15.96 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 75871334 16.74 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 75076051 16.36 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 69914791 16.31 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 64448419 16.68 ns/op 1 B/op 1 allocs/op +Benchmark_Get/StackSize100-14 70766191 16.46 ns/op 1 B/op 1 allocs/op +Benchmark_Iterate/StackSize1-14 806337 1420 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 897746 1404 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 911017 1398 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 839779 1426 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 873406 1380 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 840322 1431 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 1000000 1440 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 775245 1440 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 903236 1441 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize1-14 904930 1368 ns/op 1584 B/op 15 allocs/op +Benchmark_Iterate/StackSize10-14 28052 44257 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 27132 44182 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 27482 43655 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 28772 44653 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 26344 46040 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 26232 45708 ns/op 11089 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 26694 45973 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 27445 43115 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 25693 44260 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize10-14 27298 44350 ns/op 11088 B/op 249 allocs/op +Benchmark_Iterate/StackSize100-14 22 52325875 ns/op 117396 B/op 2733 allocs/op +Benchmark_Iterate/StackSize100-14 22 52214273 ns/op 117396 B/op 2733 allocs/op +Benchmark_Iterate/StackSize100-14 22 52066638 ns/op 117396 B/op 2733 allocs/op +Benchmark_Iterate/StackSize100-14 22 52752657 ns/op 117396 B/op 2733 allocs/op +Benchmark_Iterate/StackSize100-14 26 52589131 ns/op 115662 B/op 2710 allocs/op +Benchmark_Iterate/StackSize100-14 22 51627826 ns/op 117396 B/op 2733 allocs/op +Benchmark_Iterate/StackSize100-14 22 51819970 ns/op 117396 B/op 2733 allocs/op +Benchmark_Iterate/StackSize100-14 24 51052571 ns/op 116457 B/op 2721 allocs/op +Benchmark_Iterate/StackSize100-14 22 52228589 ns/op 117396 B/op 2733 allocs/op +Benchmark_Iterate/StackSize100-14 22 52047693 ns/op 117396 B/op 2733 allocs/op +PASS +ok cosmossdk.io/store/cachekv 133.087s diff --git a/server/v2/stf/branch/cache.go b/server/v2/stf/branch/cache.go deleted file mode 100644 index 81302c1c941f..000000000000 --- a/server/v2/stf/branch/cache.go +++ /dev/null @@ -1,28 +0,0 @@ -package branch - -import "unsafe" - -func newMemoryCache() memoryCache { - return memoryCache{ - items: map[string][]byte{}, - } -} - -type memoryCache struct { - items map[string][]byte -} - -func (l memoryCache) get(key []byte) (value []byte, found bool) { - keyStr := unsafe.String(unsafe.SliceData(key), len(key)) - - value, found = l.items[keyStr] - return -} - -func (l memoryCache) set(key, value []byte) { - l.items[string(key)] = value -} - -func (l memoryCache) delete(key []byte) { - l.items[string(key)] = nil -} diff --git a/server/v2/stf/branch/store.go b/server/v2/stf/branch/store.go index a9caa0177a0b..19e32e8392a3 100644 --- a/server/v2/stf/branch/store.go +++ b/server/v2/stf/branch/store.go @@ -10,24 +10,22 @@ var _ store.Writer = (*Store[store.Reader])(nil) // Store wraps an in-memory child around an underlying types.KVStore. type Store[T store.Reader] struct { - changeSet changeSet // ordered changeset. - memoryCache memoryCache // fast lookup map for changeset, unordered. - parent T + changeSet changeSet // ordered changeset. + parent T } // NewStore creates a new Store object func NewStore[T store.Reader](parent T) Store[T] { return Store[T]{ - changeSet: newChangeSet(), - memoryCache: newMemoryCache(), - parent: parent, + changeSet: newChangeSet(), + parent: parent, } } // Get implements types.KVStore. func (s Store[T]) Get(key []byte) (value []byte, err error) { // if found in memory cache, immediately return. - value, found := s.memoryCache.get(key) + value, found := s.changeSet.get(key) if found { return } @@ -37,7 +35,6 @@ func (s Store[T]) Get(key []byte) (value []byte, err error) { if err != nil { return nil, err } - s.memoryCache.set(key, value) return value, nil } @@ -46,10 +43,7 @@ func (s Store[T]) Set(key, value []byte) error { if value == nil { return errors.New("cannot set a nil value") } - s.changeSet.set(key, value) - s.memoryCache.set(key, value) - return nil } @@ -65,7 +59,6 @@ func (s Store[T]) Has(key []byte) (bool, error) { // Delete implements types.KVStore. func (s Store[T]) Delete(key []byte) error { s.changeSet.delete(key) - s.memoryCache.delete(key) return nil } From 332a0c7de5e97bf1de44452d219551d2e4fde8c3 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 7 Nov 2024 14:17:07 +0100 Subject: [PATCH 13/13] remove txt files --- server/v2/stf/branch/bench_22131.txt | 96 -------------------------- server/v2/stf/branch/bench_storev1.txt | 96 -------------------------- 2 files changed, 192 deletions(-) delete mode 100644 server/v2/stf/branch/bench_22131.txt delete mode 100644 server/v2/stf/branch/bench_storev1.txt diff --git a/server/v2/stf/branch/bench_22131.txt b/server/v2/stf/branch/bench_22131.txt deleted file mode 100644 index 1a169ed7efb5..000000000000 --- a/server/v2/stf/branch/bench_22131.txt +++ /dev/null @@ -1,96 +0,0 @@ -goos: darwin -goarch: arm64 -pkg: cosmossdk.io/server/v2/stf/branch -cpu: Apple M3 Max -Benchmark_CacheStack_Set/StackSize1-14 36413290 33.31 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 35942940 34.33 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 36227097 32.59 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 36985620 32.62 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 34493827 32.62 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 37298065 32.46 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 37051664 32.55 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 36883686 32.48 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 37034179 32.59 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 36960226 32.46 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 26045575 46.27 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 25950037 46.15 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 26205926 46.01 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 25982696 46.00 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 26053021 46.06 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 25772341 46.08 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 25855080 46.17 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 26162884 46.08 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 26146875 46.11 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 25878520 45.99 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 26067688 46.20 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 26085656 46.02 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 26131170 46.01 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 26144407 46.06 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 26018938 46.02 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 25682228 48.46 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 26095701 46.54 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 26147968 48.50 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 25609377 46.66 ns/op 2 B/op 2 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 25418208 46.67 ns/op 2 B/op 2 allocs/op -Benchmark_Get/StackSize1-14 47967780 24.95 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 47577195 25.19 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 47781637 24.94 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 47332609 25.00 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 47787187 25.03 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 48496687 24.83 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 48153289 24.89 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 48453279 24.69 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 48500605 24.71 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 48790486 24.77 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3676309 328.9 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3665226 327.0 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3669343 327.1 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3674840 327.2 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3667174 327.1 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3665042 327.0 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3666630 327.0 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3665234 327.5 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3680134 326.8 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 3663696 326.7 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 237254 5028 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 240108 5267 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 242304 5014 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 236968 5136 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 246918 5086 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 240165 4959 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 242150 5030 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 245880 4891 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 236239 5019 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 239452 5012 ns/op 1 B/op 1 allocs/op -Benchmark_Iterate/StackSize1-14 4859352 248.2 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4786867 250.3 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4754394 250.2 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4808739 249.5 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4803613 249.8 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4794133 250.9 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4799314 249.4 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4784235 252.0 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4848817 251.2 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize1-14 4752552 251.1 ns/op 984 B/op 7 allocs/op -Benchmark_Iterate/StackSize10-14 91701 13156 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 91626 13236 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 91365 14143 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 83239 13882 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 88155 13691 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 84646 13487 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 89509 13241 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 91993 13247 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 90870 13235 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize10-14 89091 13219 ns/op 10848 B/op 232 allocs/op -Benchmark_Iterate/StackSize100-14 831 1437972 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 831 1442003 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 830 1440507 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 832 1438528 ns/op 109494 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 836 1439228 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 828 1444444 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 836 1437128 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 836 1437714 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 834 1441704 ns/op 109488 B/op 2482 allocs/op -Benchmark_Iterate/StackSize100-14 832 1447616 ns/op 109488 B/op 2482 allocs/op -PASS -ok cosmossdk.io/server/v2/stf/branch 120.114s diff --git a/server/v2/stf/branch/bench_storev1.txt b/server/v2/stf/branch/bench_storev1.txt deleted file mode 100644 index 14d7c5cedfb1..000000000000 --- a/server/v2/stf/branch/bench_storev1.txt +++ /dev/null @@ -1,96 +0,0 @@ -goos: darwin -goarch: arm64 -pkg: cosmossdk.io/store/cachekv -cpu: Apple M3 Max -Benchmark_CacheStack_Set/StackSize1-14 23762670 50.66 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23815470 52.51 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23700504 50.09 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23894227 50.60 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23923881 51.59 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23567246 50.72 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23912976 50.76 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23585929 51.69 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 23619915 51.00 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize1-14 22026919 50.65 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 20656384 59.33 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 20070175 59.69 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 17762174 60.18 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 20686652 58.29 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 20080363 58.92 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 21156355 59.50 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 20363948 60.83 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 20779700 58.36 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 17666738 58.08 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize10-14 20784408 59.87 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 20917387 57.43 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 19810956 58.39 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 19317696 58.77 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 19808176 65.74 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 20627594 59.53 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 20669712 58.38 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 20143410 57.45 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 20125293 60.01 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 21023170 57.92 ns/op 34 B/op 3 allocs/op -Benchmark_CacheStack_Set/StackSize100-14 21142921 62.84 ns/op 34 B/op 3 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.63 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 99004795 11.54 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.58 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.67 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.57 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.47 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.88 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 99394999 11.60 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.65 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize1-14 100000000 11.94 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 71410506 17.11 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 71044978 17.04 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 73479136 16.02 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 73639016 16.63 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 72728744 16.38 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 71737082 16.13 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 76073544 15.72 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 73673114 15.55 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 70475266 16.27 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize10-14 76181808 16.57 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 69400598 18.96 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 73939244 16.36 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 71737443 15.75 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 71800394 16.43 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 72954243 15.96 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 75871334 16.74 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 75076051 16.36 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 69914791 16.31 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 64448419 16.68 ns/op 1 B/op 1 allocs/op -Benchmark_Get/StackSize100-14 70766191 16.46 ns/op 1 B/op 1 allocs/op -Benchmark_Iterate/StackSize1-14 806337 1420 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 897746 1404 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 911017 1398 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 839779 1426 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 873406 1380 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 840322 1431 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 1000000 1440 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 775245 1440 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 903236 1441 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize1-14 904930 1368 ns/op 1584 B/op 15 allocs/op -Benchmark_Iterate/StackSize10-14 28052 44257 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 27132 44182 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 27482 43655 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 28772 44653 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 26344 46040 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 26232 45708 ns/op 11089 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 26694 45973 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 27445 43115 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 25693 44260 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize10-14 27298 44350 ns/op 11088 B/op 249 allocs/op -Benchmark_Iterate/StackSize100-14 22 52325875 ns/op 117396 B/op 2733 allocs/op -Benchmark_Iterate/StackSize100-14 22 52214273 ns/op 117396 B/op 2733 allocs/op -Benchmark_Iterate/StackSize100-14 22 52066638 ns/op 117396 B/op 2733 allocs/op -Benchmark_Iterate/StackSize100-14 22 52752657 ns/op 117396 B/op 2733 allocs/op -Benchmark_Iterate/StackSize100-14 26 52589131 ns/op 115662 B/op 2710 allocs/op -Benchmark_Iterate/StackSize100-14 22 51627826 ns/op 117396 B/op 2733 allocs/op -Benchmark_Iterate/StackSize100-14 22 51819970 ns/op 117396 B/op 2733 allocs/op -Benchmark_Iterate/StackSize100-14 24 51052571 ns/op 116457 B/op 2721 allocs/op -Benchmark_Iterate/StackSize100-14 22 52228589 ns/op 117396 B/op 2733 allocs/op -Benchmark_Iterate/StackSize100-14 22 52047693 ns/op 117396 B/op 2733 allocs/op -PASS -ok cosmossdk.io/store/cachekv 133.087s