Add logging of memory status

pull/56/head
Martin Boehm 2018-08-26 21:29:10 +02:00
parent 16275601f4
commit b1e749dab9
2 changed files with 8 additions and 1 deletions

View File

@ -431,6 +431,8 @@ func storeInternalStateLoop() {
lastCompute := time.Now() lastCompute := time.Now()
// randomize the duration between ComputeInternalStateColumnStats to avoid peaks after reboot of machine with multiple blockbooks // randomize the duration between ComputeInternalStateColumnStats to avoid peaks after reboot of machine with multiple blockbooks
computePeriod := 9*time.Hour + time.Duration(rand.Float64()*float64((2*time.Hour).Nanoseconds())) computePeriod := 9*time.Hour + time.Duration(rand.Float64()*float64((2*time.Hour).Nanoseconds()))
lastLogMemory := time.Now()
logMemoryPeriod := 15 * time.Minute
glog.Info("storeInternalStateLoop starting with db stats recompute period ", computePeriod) glog.Info("storeInternalStateLoop starting with db stats recompute period ", computePeriod)
tickAndDebounce(storeInternalStatePeriodMs*time.Millisecond, (storeInternalStatePeriodMs-1)*time.Millisecond, chanStoreInternalState, func() { tickAndDebounce(storeInternalStatePeriodMs*time.Millisecond, (storeInternalStatePeriodMs-1)*time.Millisecond, chanStoreInternalState, func() {
if !computeRunning && lastCompute.Add(computePeriod).Before(time.Now()) { if !computeRunning && lastCompute.Add(computePeriod).Before(time.Now()) {
@ -447,6 +449,10 @@ func storeInternalStateLoop() {
if err := index.StoreInternalState(internalState); err != nil { if err := index.StoreInternalState(internalState); err != nil {
glog.Error("storeInternalStateLoop ", errors.ErrorStack(err)) glog.Error("storeInternalStateLoop ", errors.ErrorStack(err))
} }
if lastLogMemory.Add(logMemoryPeriod).Before(time.Now()) {
glog.Info(index.GetMemoryStats())
lastLogMemory = time.Now()
}
}) })
glog.Info("storeInternalStateLoop stopped") glog.Info("storeInternalStateLoop stopped")
} }

View File

@ -308,7 +308,8 @@ ConnectLoop:
} }
if msTime.Before(time.Now()) { if msTime.Before(time.Now()) {
glog.Info(w.db.GetMemoryStats()) glog.Info(w.db.GetMemoryStats())
msTime = time.Now().Add(1 * time.Minute) w.metrics.IndexDBSize.Set(float64(w.db.DatabaseSizeOnDisk()))
msTime = time.Now().Add(10 * time.Minute)
} }
h++ h++
} }