MCPcopy
hub / github.com/dgraph-io/dgraph / MonitorCacheHealth

Function MonitorCacheHealth

x/metrics.go:718–733  ·  view source on GitHub ↗

MonitorCacheHealth periodically monitors the cache metrics and reports if there is high contention in the cache.

(db *badger.DB, closer *z.Closer)

Source from the content-addressed store, hash-verified

716// MonitorCacheHealth periodically monitors the cache metrics and reports if
717// there is high contention in the cache.
718func MonitorCacheHealth(db *badger.DB, closer *z.Closer) {
719 defer closer.Done()
720
721 ticker := time.Tick(10 * time.Second)
722 backgroundContext := context.Background()
723
724 for {
725 select {
726 case <-ticker:
727 ostats.Record(backgroundContext, PBlockHitRatio.M(db.BlockCacheMetrics().Ratio()))
728 ostats.Record(backgroundContext, PIndexHitRatio.M(db.IndexCacheMetrics().Ratio()))
729 case <-closer.HasBeenClosed():
730 return
731 }
732 }
733}
734
735func MonitorMemoryMetrics(lc *z.Closer) {
736 defer lc.Done()

Callers 1

InitStorageMethod · 0.92

Calls 2

RecordMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected