@@ -292,6 +292,7 @@ func (t *SizeTracker) run() {
292292 case u := <- t .updateCh :
293293 base , found := stats [u .originRoot ]
294294 if ! found {
295+ log .Debug ("Ignored the state size without parent" , "parent" , u .originRoot , "root" , u .root , "number" , u .blockNumber )
295296 continue
296297 }
297298 diff , err := calSizeStats (u )
@@ -352,8 +353,6 @@ wait:
352353 done chan buildResult
353354 )
354355
355- t .triedb .SetForceFlush (true )
356-
357356 for {
358357 select {
359358 case u := <- t .updateCh :
@@ -378,8 +377,6 @@ wait:
378377 log .Info ("Measuring persistent state size" , "root" , root .Hex (), "number" , entry .blockNumber )
379378
380379 case result := <- done :
381- t .triedb .SetForceFlush (false )
382-
383380 if result .err != nil {
384381 return nil , result .err
385382 }
@@ -410,6 +407,7 @@ wait:
410407
411408 // Set initial latest stats
412409 stats [result .root ] = result .stat
410+
413411 t .mu .Lock ()
414412 t .latestStats = & result .stat
415413 t .mu .Unlock ()
@@ -561,16 +559,18 @@ func (t *SizeTracker) iterateTable(closed chan struct{}, prefix []byte, name str
561559 return count , bytes , nil
562560}
563561
564- // iterateTableParallel performs parallel iteration over a table by splitting into hex ranges
565- // For storage tables, it splits on the first byte of the account hash (after the prefix)
562+ // iterateTableParallel performs parallel iteration over a table by splitting into
563+ // hex ranges. For storage tables, it splits on the first byte of the account hash
564+ // (after the prefix).
566565func (t * SizeTracker ) iterateTableParallel (closed chan struct {}, prefix []byte , name string ) (int64 , int64 , error ) {
567566 var (
568- start = time .Now ()
569- workers = runtime .NumCPU ()
570567 totalCount int64
571568 totalBytes int64
572- group errgroup.Group
573- mu sync.Mutex
569+
570+ start = time .Now ()
571+ workers = runtime .NumCPU ()
572+ group errgroup.Group
573+ mu sync.Mutex
574574 )
575575 group .SetLimit (workers )
576576
@@ -598,11 +598,9 @@ func (t *SizeTracker) iterateTableParallel(closed chan struct{}, prefix []byte,
598598 return nil
599599 })
600600 }
601-
602601 if err := group .Wait (); err != nil {
603602 return 0 , 0 , err
604603 }
605-
606604 log .Info ("Finished parallel state iteration" , "category" , name , "count" , totalCount , "size" , common .StorageSize (totalBytes ), "elapsed" , common .PrettyDuration (time .Since (start )))
607605 return totalCount , totalBytes , nil
608606}
@@ -611,5 +609,6 @@ func (t *SizeTracker) iterateTableParallel(closed chan struct{}, prefix []byte,
611609func (t * SizeTracker ) GetLatestStats () * SizeStats {
612610 t .mu .RLock ()
613611 defer t .mu .RUnlock ()
612+
614613 return t .latestStats
615614}
0 commit comments