예제 #1
0
// 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)
}
예제 #2
0
// 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)
}
예제 #3
0
// GetGCBytesAge returns the total age of outstanding gc'able
// bytes, based on current wall time specified via nowNanos.
func (rs *rangeStats) GetGCBytesAge(nowNanos int64) int64 {
	rs.Lock()
	defer rs.Unlock()
	gcBytes := (rs.KeyBytes + rs.ValBytes - rs.LiveBytes)
	if gcBytes == 0 {
		return 0
	}
	// Advance gc bytes age by any elapsed time since last computed.
	elapsedSeconds := nowNanos/1E9 - rs.LastUpdateNanos/1E9
	return rs.GCBytesAge + engine.MVCCComputeGCBytesAge(gcBytes, elapsedSeconds)
}