-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Speedup cachekv iterator on large deletions & IBC v2 upgrade lo…
…gic (backport #10741) (#10746) * perf: Speedup cachekv iterator on large deletions & IBC v2 upgrade logic (#10741) (cherry picked from commit 314e1d5) # Conflicts: # CHANGELOG.md # store/cachekv/store_bench_test.go * fix conflicts Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> Co-authored-by: marbar3778 <marbar3778@yahoo.com>
- Loading branch information
1 parent
01fac64
commit c81d3d6
Showing
4 changed files
with
179 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cachekv_test | ||
|
||
import "crypto/rand" | ||
|
||
func randSlice(sliceSize int) []byte { | ||
bz := make([]byte, sliceSize) | ||
_, _ = rand.Read(bz) | ||
return bz | ||
} | ||
|
||
func incrementByteSlice(bz []byte) { | ||
for index := len(bz) - 1; index >= 0; index-- { | ||
if bz[index] < 255 { | ||
bz[index]++ | ||
break | ||
} else { | ||
bz[index] = 0 | ||
} | ||
} | ||
} | ||
|
||
// Generate many keys starting at startKey, and are in sequential order | ||
func generateSequentialKeys(startKey []byte, numKeys int) [][]byte { | ||
toReturn := make([][]byte, 0, numKeys) | ||
cur := make([]byte, len(startKey)) | ||
copy(cur, startKey) | ||
for i := 0; i < numKeys; i++ { | ||
newKey := make([]byte, len(startKey)) | ||
copy(newKey, cur) | ||
toReturn = append(toReturn, newKey) | ||
incrementByteSlice(cur) | ||
} | ||
return toReturn | ||
} | ||
|
||
// Generate many random, unsorted keys | ||
func generateRandomKeys(keySize int, numKeys int) [][]byte { | ||
toReturn := make([][]byte, 0, numKeys) | ||
for i := 0; i < numKeys; i++ { | ||
newKey := randSlice(keySize) | ||
toReturn = append(toReturn, newKey) | ||
} | ||
return toReturn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters