Change memory usage by minus cache memory
Signed-off-by: Sun Jianbo <wonderflow@zju.edu.cn> Add stats.cache into MemoryStats add cache to the output then client can clarify the results. Signed-off-by: Sun Jianbo <wonderflow@zju.edu.cn> Do not subtract cache from usage Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
b0fbd0591a
commit
2c3949a687
|
@ -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)
|
||||
}
|
||||
stats.MemoryStats.Usage = value
|
||||
stats.MemoryStats.Cache = stats.MemoryStats.Stats["cache"]
|
||||
value, err = getCgroupParamUint(path, "memory.max_usage_in_bytes")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse memory.max_usage_in_bytes - %v", err)
|
||||
|
|
|
@ -128,7 +128,7 @@ func TestMemoryStats(t *testing.T) {
|
|||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ type CpuStats struct {
|
|||
type MemoryStats struct {
|
||||
// current res_counter usage for memory
|
||||
Usage uint64 `json:"usage,omitempty"`
|
||||
// memory used for cache
|
||||
Cache uint64 `json:"cache,omitempty"`
|
||||
// maximum usage ever recorded.
|
||||
MaxUsage uint64 `json:"max_usage,omitempty"`
|
||||
// TODO(vishh): Export these as stronger types.
|
||||
|
|
Loading…
Reference in New Issue