diff --git a/ethdb/mutation.go b/ethdb/mutation.go index f09ff2a814cca8c8724a7e05758dff9a8d9b8172..8f794cfffebfcb48d019287a4c2708845d1800da 100644 --- a/ethdb/mutation.go +++ b/ethdb/mutation.go @@ -7,11 +7,13 @@ import ( "strings" "sync" "sync/atomic" + "time" "unsafe" "github.com/c2h5oh/datasize" "github.com/google/btree" "github.com/ledgerwatch/turbo-geth/common" + "github.com/ledgerwatch/turbo-geth/log" "github.com/ledgerwatch/turbo-geth/metrics" ) @@ -200,6 +202,11 @@ func (m *mutation) doCommit(tx Tx) error { var c Cursor var innerErr error var isEndOfBucket bool + logEvery := time.NewTicker(30 * time.Second) + defer logEvery.Stop() + count := 0 + total := float64(m.puts.Len()) + m.puts.Ascend(func(i btree.Item) bool { mi := i.(*MutationItem) if mi.table != prevTable { @@ -233,6 +240,15 @@ func (m *mutation) doCommit(tx Tx) error { return false } } + + count++ + + select { + default: + case <-logEvery.C: + progress := fmt.Sprintf("%.1fM/%.1fM", float64(count)/1_000_000, total/1_000_000) + log.Info("Write to db", "progress", progress, "current table", mi.table) + } return true }) return innerErr