remove avg memory usage

This commit is contained in:
Nan Deng 2014-06-12 11:36:17 -07:00
parent 5373161db3
commit f07a91c0cc
3 changed files with 7 additions and 26 deletions

View File

@ -15,7 +15,6 @@
package container
import (
"math/big"
"sync"
"time"
@ -24,13 +23,12 @@ import (
)
type statsSummaryContainerHandlerWrapper struct {
handler ContainerHandler
currentSummary *info.ContainerStatsSummary
prevStats *info.ContainerStats
totalMemoryUsage *big.Int
numStats uint64
sampler sampling.Sampler
lock sync.Mutex
handler ContainerHandler
currentSummary *info.ContainerStatsSummary
prevStats *info.ContainerStats
numStats uint64
sampler sampling.Sampler
lock sync.Mutex
}
func (self *statsSummaryContainerHandlerWrapper) GetSpec() (*info.ContainerSpec, error) {
@ -87,16 +85,6 @@ func (self *statsSummaryContainerHandlerWrapper) GetStats() (*info.ContainerStat
if stats.Memory.Usage > self.currentSummary.MaxMemoryUsage {
self.currentSummary.MaxMemoryUsage = stats.Memory.Usage
}
// XXX(dengnan): Very inefficient!
if self.totalMemoryUsage == nil {
self.totalMemoryUsage = new(big.Int)
}
usage := (&big.Int{}).SetUint64(stats.Memory.Usage)
self.totalMemoryUsage = self.totalMemoryUsage.Add(self.totalMemoryUsage, usage)
n := (&big.Int{}).SetUint64(self.numStats)
avg := (&big.Int{}).Div(self.totalMemoryUsage, n)
self.currentSummary.AvgMemoryUsage = avg.Uint64()
}
return stats, nil
}

View File

@ -64,7 +64,7 @@ func (self *randomMemoryUsageContainer) GetStats() (*info.ContainerStats, error)
return stats, nil
}
func TestAvgMaxMemoryUsage(t *testing.T) {
func TestMaxMemoryUsage(t *testing.T) {
handler, err := AddStatsSummary(
&randomMemoryUsageContainer{},
&StatsParameter{
@ -76,7 +76,6 @@ func TestAvgMaxMemoryUsage(t *testing.T) {
t.Error(err)
}
var maxUsage uint64
var totalUsage uint64
N := 100
for i := 0; i < N; i++ {
stats, err := handler.GetStats()
@ -87,7 +86,6 @@ func TestAvgMaxMemoryUsage(t *testing.T) {
if stats.Memory.Usage > maxUsage {
maxUsage = stats.Memory.Usage
}
totalUsage += stats.Memory.Usage
}
summary, err := handler.StatsSummary()
if err != nil {
@ -96,10 +94,6 @@ func TestAvgMaxMemoryUsage(t *testing.T) {
if summary.MaxMemoryUsage != maxUsage {
t.Fatalf("Max memory usage should be %v; received %v", maxUsage, summary.MaxMemoryUsage)
}
avg := totalUsage / uint64(N)
if summary.AvgMemoryUsage != avg {
t.Fatalf("Avg memory usage should be %v; received %v", avg, summary.AvgMemoryUsage)
}
}
type replayCpuTrace struct {

View File

@ -180,7 +180,6 @@ type percentile struct {
type ContainerStatsSummary struct {
// TODO(dengnan): More things?
MaxMemoryUsage uint64 `json:"max_memory_usage,omitempty"`
AvgMemoryUsage uint64 `json:"avg_memory_usage,omitempty"`
Samples []*ContainerStatsSample `json:"samples,omitempty"`
MemoryUsagePercentiles []percentile `json:"memory_usage_percentiles,omitempty"`
CpuUsagePercentiles []percentile `json:"cpu_usage_percentiles,omitempty"`