Skip to content

Commit 0b13632

Browse files
jsvisarjl493456442
authored andcommitted
fix: special case for the prefix only key
1 parent 6f0f67b commit 0b13632

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/state/state_sizer.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"maps"
24+
"runtime"
2425
"slices"
2526
"sync"
2627
"time"
@@ -565,7 +566,7 @@ func (t *SizeTracker) iterateTable(closed chan struct{}, prefix []byte, name str
565566
func (t *SizeTracker) iterateTableParallel(closed chan struct{}, prefix []byte, name string) (int64, int64, error) {
566567
var (
567568
start = time.Now()
568-
workers = 16
569+
workers = runtime.NumCPU()
569570
totalCount int64
570571
totalBytes int64
571572
group errgroup.Group
@@ -575,6 +576,14 @@ func (t *SizeTracker) iterateTableParallel(closed chan struct{}, prefix []byte,
575576

576577
log.Info("Starting parallel state iteration", "category", name, "workers", workers)
577578

579+
if len(prefix) > 0 {
580+
if blob, err := t.db.Get(prefix); err == nil && len(blob) > 0 {
581+
// If there's a direct hit on the prefix, include it in the stats
582+
totalCount = 1
583+
totalBytes = int64(len(prefix) + len(blob))
584+
}
585+
}
586+
578587
for i := 0; i < 256; i++ {
579588
h := byte(i)
580589
group.Go(func() error {

0 commit comments

Comments
 (0)