Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.
Merged
Changes from all commits
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
4 changes: 4 additions & 0 deletions tools/cmd/seidb/operations/state_size.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func PrintStateSize(module string, db *memiavl.DB) error {
fmt.Printf("Calculating for module: %s \n", moduleName)
keySizeByPrefix := map[string]int64{}
valueSizeByPrefix := map[string]int64{}
numKeysByPrefix := map[string]int64{}
tree.ScanPostOrder(func(node memiavl.Node) bool {
if node.IsLeaf() {
totalNumKeys++
Expand All @@ -81,6 +82,7 @@ func PrintStateSize(module string, db *memiavl.DB) error {
prefix = prefix[:2]
keySizeByPrefix[prefix] += int64(keySize)
valueSizeByPrefix[prefix] += int64(valueSize)
numKeysByPrefix[prefix]++
}
return true
})
Expand All @@ -89,6 +91,8 @@ func PrintStateSize(module string, db *memiavl.DB) error {
fmt.Printf("Module %s prefix key size breakdown (bytes): %s \n", moduleName, prefixKeyResult)
prefixValueResult, _ := json.MarshalIndent(valueSizeByPrefix, "", " ")
fmt.Printf("Module %s prefix value size breakdown (bytes): %s \n", moduleName, prefixValueResult)
numKeysResult, _ := json.MarshalIndent(numKeysByPrefix, "", " ")
fmt.Printf("Module %s prefix num of keys breakdown: %s \n", moduleName, numKeysResult)

// Print top 20 contracts by total size
numToShow := 20
Expand Down
Loading