Merge pull request #518 from crosbymichael/memcache

Add cache to MemoryStats
This commit is contained in:
Michael Crosby 2015-04-09 13:57:13 -07:00
commit cc555cce5f
3 changed files with 4 additions and 1 deletions

View File

@ -95,6 +95,7 @@ func (s *MemoryGroup) GetStats(path string, stats *cgroups.Stats) error {
return fmt.Errorf("failed to parse memory.usage_in_bytes - %v", err) return fmt.Errorf("failed to parse memory.usage_in_bytes - %v", err)
} }
stats.MemoryStats.Usage = value stats.MemoryStats.Usage = value
stats.MemoryStats.Cache = stats.MemoryStats.Stats["cache"]
value, err = getCgroupParamUint(path, "memory.max_usage_in_bytes") value, err = getCgroupParamUint(path, "memory.max_usage_in_bytes")
if err != nil { if err != nil {
return fmt.Errorf("failed to parse memory.max_usage_in_bytes - %v", err) return fmt.Errorf("failed to parse memory.max_usage_in_bytes - %v", err)

View File

@ -128,7 +128,7 @@ func TestMemoryStats(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
expectedStats := cgroups.MemoryStats{Usage: 2048, MaxUsage: 4096, Failcnt: 100, Stats: map[string]uint64{"cache": 512, "rss": 1024}} expectedStats := cgroups.MemoryStats{Usage: 2048, Cache: 512, MaxUsage: 4096, Failcnt: 100, Stats: map[string]uint64{"cache": 512, "rss": 1024}}
expectMemoryStatEquals(t, expectedStats, actualStats.MemoryStats) expectMemoryStatEquals(t, expectedStats, actualStats.MemoryStats)
} }

View File

@ -33,6 +33,8 @@ type CpuStats struct {
type MemoryStats struct { type MemoryStats struct {
// current res_counter usage for memory // current res_counter usage for memory
Usage uint64 `json:"usage,omitempty"` Usage uint64 `json:"usage,omitempty"`
// memory used for cache
Cache uint64 `json:"cache,omitempty"`
// maximum usage ever recorded. // maximum usage ever recorded.
MaxUsage uint64 `json:"max_usage,omitempty"` MaxUsage uint64 `json:"max_usage,omitempty"`
// TODO(vishh): Export these as stronger types. // TODO(vishh): Export these as stronger types.