finish add write elapsed

Signed-off-by: Delweng <delweng@gmail.com>
This commit is contained in:
Delweng 2025-07-24 15:18:04 +08:00 committed by jsvisa
parent 2b64c5c938
commit 26a17bc410

View file

@ -208,6 +208,8 @@ func (b *batchIndexer) finish(force bool) error {
if err := eg.Wait(); err != nil { if err := eg.Wait(); err != nil {
return err return err
} }
mtime := time.Now()
// Update the position of last indexed state history // Update the position of last indexed state history
if !b.delete { if !b.delete {
storeIndexMetadata(batch, b.lastID) storeIndexMetadata(batch, b.lastID)
@ -218,10 +220,14 @@ func (b *batchIndexer) finish(force bool) error {
storeIndexMetadata(batch, b.lastID-1) storeIndexMetadata(batch, b.lastID-1)
} }
} }
wtime := time.Now()
if err := batch.Write(); err != nil { if err := batch.Write(); err != nil {
return err return err
} }
log.Debug("Committed batch indexer", "accounts", len(b.accounts), "storages", storages, "records", b.counter, "elapsed", common.PrettyDuration(time.Since(start))) log.Debug("Committed batch indexer", "accounts", len(b.accounts), "storages", storages, "records", b.counter, "elapsed", common.PrettyDuration(time.Since(start)),
"mtime", common.PrettyDuration(mtime.Sub(start)),
"utime", common.PrettyDuration(wtime.Sub(mtime)),
"wtime", common.PrettyDuration(time.Since(wtime)))
b.counter = 0 b.counter = 0
b.accounts = make(map[common.Hash][]uint64) b.accounts = make(map[common.Hash][]uint64)
b.storages = make(map[common.Hash]map[common.Hash][]uint64) b.storages = make(map[common.Hash]map[common.Hash][]uint64)