log final counts when process completes

This commit is contained in:
i-norden 2021-12-28 23:42:19 -06:00
parent b5d31748e0
commit e50bd160fe
2 changed files with 13 additions and 7 deletions

View File

@ -183,13 +183,17 @@ func (p *Publisher) checkBatchSize(tx *sqlx.Tx, maxBatchSize uint) (*sqlx.Tx, er
return tx, nil
}
// printNodeCounters prints number of node processed.
func (p *Publisher) printNodeCounters() {
// logNodeCounters periodically logs the number of node processed.
func (p *Publisher) logNodeCounters() {
t := time.NewTicker(logInterval)
for range t.C {
logrus.Infof("total runtime: %s", time.Now().Sub(p.startTime).String())
p.printNodeCounters()
}
}
func (p *Publisher) printNodeCounters() {
logrus.Infof("runtime: %s", time.Now().Sub(p.startTime).String())
logrus.Infof("processed state nodes: %d", atomic.LoadUint64(&p.stateNodeCounter))
logrus.Infof("processed storage nodes: %d", atomic.LoadUint64(&p.storageNodeCounter))
logrus.Infof("processed code nodes: %d", atomic.LoadUint64(&p.codeNodeCounter))
}
}

View File

@ -136,8 +136,10 @@ func (s *Service) createSnapshot(it trie.NodeIterator, trieDB *trie.Database, he
return err
}
go s.ipfsPublisher.printNodeCounters()
go s.ipfsPublisher.logNodeCounters()
defer func() {
logrus.Info("----- final counts -----")
s.ipfsPublisher.printNodeCounters()
if rec := recover(); rec != nil {
shared.Rollback(tx)
panic(rec)