You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by id...@apache.org on 2015/06/13 01:05:14 UTC

[2/2] mesos git commit: MemIsolator: Improved some statistics naming.

MemIsolator: Improved some statistics naming.

See MESOS-2104 for details.

Review: https://reviews.apache.org/r/31915


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ecb2303c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ecb2303c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ecb2303c

Branch: refs/heads/master
Commit: ecb2303ca180652cab07e56deef10364f0a94ca1
Parents: f1254a6
Author: Chi Zhang <ch...@gmail.com>
Authored: Fri Jun 12 16:04:03 2015 -0700
Committer: Ian Downes <id...@twitter.com>
Committed: Fri Jun 12 16:04:04 2015 -0700

----------------------------------------------------------------------
 include/mesos/mesos.proto                       | 33 ++++++++++++++++++--
 .../containerizer/isolators/cgroups/mem.cpp     | 29 +++++++++++++++--
 2 files changed, 56 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ecb2303c/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index 2034009..e5b9884 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -566,15 +566,42 @@ message ResourceStatistics {
   optional double cpus_throttled_time_secs = 9;
 
   // Memory Usage Information:
-  optional uint64 mem_rss_bytes = 5; // Resident Set Size.
 
-  // Amount of memory resources allocated.
+  // mem_total_bytes was added in 0.23.0 to represent the total memory
+  // of a process in RAM (as opposed to in Swap). This was previously
+  // reported as mem_rss_bytes, which was also changed in 0.23.0 to
+  // represent only the anonymous memory usage, to keep in sync with
+  // Linux kernel's (arguably erroneous) use of terminology.
+  optional uint64 mem_total_bytes = 36;
+
+  // Total memory + swap usage. This is set if swap is enabled.
+  optional uint64 mem_total_memsw_bytes = 37;
+
+  // Hard memory limit for a container.
   optional uint64 mem_limit_bytes = 6;
 
-  // Broken out memory usage information (files, anonymous, and mmaped files)
+  // Soft memory limit for a container.
+  optional uint64 mem_soft_limit_bytes = 38;
+
+  // Broken out memory usage information: pagecache, rss (anonymous),
+  // mmaped files and swap.
+
+  // TODO(chzhcn) mem_file_bytes and mem_anon_bytes are deprecated in
+  // 0.23.0 and will be removed in 0.24.0.
   optional uint64 mem_file_bytes = 10;
   optional uint64 mem_anon_bytes = 11;
+
+  // mem_cache_bytes is added in 0.23.0 to represent page cache usage.
+  optional uint64 mem_cache_bytes = 39;
+
+  // Since 0.23.0, mem_rss_bytes is changed to represent only
+  // anonymous memory usage. Note that neither its requiredness, type,
+  // name nor numeric tag has been changed.
+  optional uint64 mem_rss_bytes = 5;
+
   optional uint64 mem_mapped_file_bytes = 12;
+  // This is only set if swap is enabled.
+  optional uint64 mem_swap_bytes = 40;
 
   // Number of occurrences of different levels of memory pressure
   // events reported by memory cgroup. Pressure listening (re)starts

http://git-wip-us.apache.org/repos/asf/mesos/blob/ecb2303c/src/slave/containerizer/isolators/cgroups/mem.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/cgroups/mem.cpp b/src/slave/containerizer/isolators/cgroups/mem.cpp
index 9647e79..7fb6c8a 100644
--- a/src/slave/containerizer/isolators/cgroups/mem.cpp
+++ b/src/slave/containerizer/isolators/cgroups/mem.cpp
@@ -429,25 +429,43 @@ Future<ResourceStatistics> CgroupsMemIsolatorProcess::usage(
     return Failure("Failed to parse memory.usage_in_bytes: " + usage.error());
   }
 
+  result.set_mem_total_bytes(usage.get().bytes());
+
+  if (limitSwap) {
+    Try<Bytes> usage =
+      cgroups::memory::memsw_usage_in_bytes(hierarchy, info->cgroup);
+    if (usage.isError()) {
+      return Failure(
+        "Failed to parse memory.memsw.usage_in_bytes: " + usage.error());
+    }
+
+    result.set_mem_total_memsw_bytes(usage.get().bytes());
+  }
+
   // TODO(bmahler): Add namespacing to cgroups to enforce the expected
   // structure, e.g, cgroups::memory::stat.
-  result.set_mem_rss_bytes(usage.get().bytes());
-
   Try<hashmap<string, uint64_t>> stat =
     cgroups::stat(hierarchy, info->cgroup, "memory.stat");
-
   if (stat.isError()) {
     return Failure("Failed to read memory.stat: " + stat.error());
   }
 
   Option<uint64_t> total_cache = stat.get().get("total_cache");
   if (total_cache.isSome()) {
+    // TODO(chzhcn): mem_file_bytes is deprecated in 0.23.0 and will
+    // be removed in 0.24.0.
     result.set_mem_file_bytes(total_cache.get());
+
+    result.set_mem_cache_bytes(total_cache.get());
   }
 
   Option<uint64_t> total_rss = stat.get().get("total_rss");
   if (total_rss.isSome()) {
+    // TODO(chzhcn): mem_anon_bytes is deprecated in 0.23.0 and will
+    // be removed in 0.24.0.
     result.set_mem_anon_bytes(total_rss.get());
+
+    result.set_mem_rss_bytes(total_rss.get());
   }
 
   Option<uint64_t> total_mapped_file = stat.get().get("total_mapped_file");
@@ -455,6 +473,11 @@ Future<ResourceStatistics> CgroupsMemIsolatorProcess::usage(
     result.set_mem_mapped_file_bytes(total_mapped_file.get());
   }
 
+  Option<uint64_t> total_swap = stat.get().get("total_swap");
+  if (total_swap.isSome()) {
+    result.set_mem_swap_bytes(total_swap.get());
+  }
+
   // Get pressure counter readings.
   list<Level> levels;
   list<Future<uint64_t>> values;