// MergeMVCCStats merges the results of an MVCC operation or series of // MVCC operations into the range's stats. The intent age is augmented // by multiplying the previous intent count by the elapsed nanos since // the last update to range stats. func (rs *rangeStats) MergeMVCCStats(e engine.Engine, ms *engine.MVCCStats, nowNanos int64) { // Augment the current intent age. diffSeconds := nowNanos/1E9 - rs.LastUpdateNanos/1E9 ms.LastUpdateNanos = nowNanos - rs.LastUpdateNanos ms.IntentAge += rs.IntentCount * diffSeconds ms.GCBytesAge += engine.MVCCComputeGCBytesAge(rs.KeyBytes+rs.ValBytes-rs.LiveBytes, diffSeconds) ms.MergeStats(e, rs.raftID) }
// MergeMVCCStats merges the results of an MVCC operation or series of // MVCC operations into the range's stats. The intent age is augmented // by multiplying the previous intent count by the elapsed nanos since // the last update to range stats. Stats are stored to the underlying // engine and the rangeStats MVCCStats updated to reflect merged totals. func (rs *rangeStats) MergeMVCCStats(e engine.Engine, ms *engine.MVCCStats, nowNanos int64) error { rs.Lock() defer rs.Unlock() // Augment the current intent age. diffSeconds := nowNanos/1E9 - rs.LastUpdateNanos/1E9 ms.LastUpdateNanos = nowNanos ms.IntentAge += rs.IntentCount * diffSeconds ms.GCBytesAge += engine.MVCCComputeGCBytesAge(rs.KeyBytes+rs.ValBytes-rs.LiveBytes, diffSeconds) rs.MVCCStats.Add(ms) return engine.MVCCSetRangeStats(e, rs.rangeID, &rs.MVCCStats) }