mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
eth/protocols/snap: add healing and syncing metrics
This commit is contained in:
parent
83aa643621
commit
0a965ba99f
2 changed files with 10 additions and 1 deletions
|
|
@ -66,4 +66,7 @@ var (
|
||||||
// discarded during the snap sync.
|
// discarded during the snap sync.
|
||||||
largeStorageDiscardGauge = metrics.NewRegisteredGauge("eth/protocols/snap/sync/storage/chunk/discard", nil)
|
largeStorageDiscardGauge = metrics.NewRegisteredGauge("eth/protocols/snap/sync/storage/chunk/discard", nil)
|
||||||
largeStorageResumedGauge = metrics.NewRegisteredGauge("eth/protocols/snap/sync/storage/chunk/resume", nil)
|
largeStorageResumedGauge = metrics.NewRegisteredGauge("eth/protocols/snap/sync/storage/chunk/resume", nil)
|
||||||
|
|
||||||
|
syncTimeGauge = metrics.NewRegisteredGauge("eth/protocols/snap/sync/time", nil)
|
||||||
|
healTimeGauge = metrics.NewRegisteredGauge("eth/protocols/snap/heal/time", nil)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -679,12 +679,15 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
|
||||||
bytecodeHealReqFails = make(chan *bytecodeHealRequest)
|
bytecodeHealReqFails = make(chan *bytecodeHealRequest)
|
||||||
trienodeHealResps = make(chan *trienodeHealResponse)
|
trienodeHealResps = make(chan *trienodeHealResponse)
|
||||||
bytecodeHealResps = make(chan *bytecodeHealResponse)
|
bytecodeHealResps = make(chan *bytecodeHealResponse)
|
||||||
|
syncTime = time.Now()
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
// Remove all completed tasks and terminate sync if everything's done
|
// Remove all completed tasks and terminate sync if everything's done
|
||||||
s.cleanStorageTasks()
|
s.cleanStorageTasks()
|
||||||
s.cleanAccountTasks()
|
s.cleanAccountTasks()
|
||||||
if len(s.tasks) == 0 && s.healer.scheduler.Pending() == 0 {
|
if len(s.tasks) == 0 && s.healer.scheduler.Pending() == 0 {
|
||||||
|
// healing done
|
||||||
|
healTimeGauge.Update(int64(time.Since(syncTime)))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Assign all the data retrieval tasks to any free peers
|
// Assign all the data retrieval tasks to any free peers
|
||||||
|
|
@ -693,7 +696,10 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error {
|
||||||
s.assignStorageTasks(storageResps, storageReqFails, cancel)
|
s.assignStorageTasks(storageResps, storageReqFails, cancel)
|
||||||
|
|
||||||
if len(s.tasks) == 0 {
|
if len(s.tasks) == 0 {
|
||||||
// Sync phase done, run heal phase
|
// Sync phase done, push elapsed time to metrics
|
||||||
|
syncTimeGauge.Update(int64(time.Since(s.startTime)))
|
||||||
|
syncTime = time.Now()
|
||||||
|
// run heal phase
|
||||||
s.assignTrienodeHealTasks(trienodeHealResps, trienodeHealReqFails, cancel)
|
s.assignTrienodeHealTasks(trienodeHealResps, trienodeHealReqFails, cancel)
|
||||||
s.assignBytecodeHealTasks(bytecodeHealResps, bytecodeHealReqFails, cancel)
|
s.assignBytecodeHealTasks(bytecodeHealResps, bytecodeHealReqFails, cancel)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue