diff options
author | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-06-21 15:49:35 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-06-21 15:49:35 +0200 |
commit | 1e55ec0a0e4c42ea9f6b6d0468bb848696b5255a (patch) | |
tree | 9ba2df43dda45275a0115d3f21d802960f7e740b | |
parent | 05b97d110229d5633b733b29fb93c785c8256346 (diff) |
Add javadoc and simplify method
4 files changed, 16 insertions, 8 deletions
diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java index 70ba58cd9cf..bd8ffb0163c 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerResources.java @@ -9,7 +9,7 @@ import java.util.Objects; public class ContainerResources { public static final ContainerResources UNLIMITED = ContainerResources.from(0, 0, 0); - private static final int CPU_PERIOD = 100_000; // 100 µs + public static final int CPU_PERIOD_US = 100_000; // 100 ms /** * Hard limit on container's CPU usage: Implemented using Completely Fair Scheduler (CFS) by allocating a given @@ -65,11 +65,12 @@ public class ContainerResources { // Although docker allows to update cpu quota to 0, this is not a legal value, must be set -1 for unlimited // See: https://github.com/docker/for-linux/issues/558 public int cpuQuota() { - return cpus > 0 ? (int) (cpus * CPU_PERIOD) : -1; + return cpus > 0 ? (int) (cpus * CPU_PERIOD_US) : -1; } + /** Duration (in µs) of a single period used as the basis for process scheduling */ public int cpuPeriod() { - return CPU_PERIOD; + return CPU_PERIOD_US; } public int cpuShares() { diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerStats.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerStats.java index 7fbe47b011c..797dffdef1f 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerStats.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/ContainerStats.java @@ -111,14 +111,20 @@ public class ContainerStats { } public int getOnlineCpus() { return this.onlineCpus; } + + /** Total CPU time (in ns) spent executing all the processes on this host */ public long getSystemCpuUsage() { return this.systemCpuUsage; } + + /** Total CPU time (in ns) spent running all the processes in this container */ public long getTotalUsage() { return totalUsage; } + + /** Total CPU time (in ns) spent in kernel mode while executing processes in this container */ public long getUsageInKernelMode() { return usageInKernelMode; } - /** Total CPU time processes in this container were throttled for */ + /** Total CPU time (in ns) processes in this container were throttled for */ public long getThrottledTime() { return throttledTime; } - /** Number of periods when throttling enabled for this container */ + /** Number of periods with throttling enabled for this container */ public long getThrottlingActivePeriods() { return throttlingActivePeriods; } /** Number of periods this container hit the throttling limit */ diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java index 3a9eae45607..4bf361e0e56 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java @@ -623,6 +623,7 @@ public class NodeAgentImpl implements NodeAgent { class CpuUsageReporter { private static final double BILLION = 1_000_000_000d; + private static final double PERIOD_IN_SECONDS = ContainerResources.CPU_PERIOD_US / 1_000_000d; private long containerKernelUsage = 0; private long totalContainerUsage = 0; private long totalSystemUsage = 0; @@ -667,11 +668,11 @@ public class NodeAgentImpl implements NodeAgent { } double getThrottledTime() { - return deltaSystemUsage == 0 ? Double.NaN : 60d * deltaThrottledPeriods / deltaThrottlingActivePeriods; + return deltaThrottlingActivePeriods == 0 ? Double.NaN : deltaThrottledPeriods * PERIOD_IN_SECONDS; } double getThrottledCpuTime() { - return deltaSystemUsage == 0 ? Double.NaN : deltaThrottledTime / BILLION; + return deltaThrottlingActivePeriods == 0 ? Double.NaN : deltaThrottledTime / BILLION; } } diff --git a/node-admin/src/test/resources/expected.container.system.metrics.txt b/node-admin/src/test/resources/expected.container.system.metrics.txt index 4876466d8ca..9f32be2a0c9 100644 --- a/node-admin/src/test/resources/expected.container.system.metrics.txt +++ b/node-admin/src/test/resources/expected.container.system.metrics.txt @@ -11,7 +11,7 @@ s: "metrics": { "cpu.sys.util": 3.402, "cpu.throttled_cpu_time": 290.0, - "cpu.throttled_time": 49.473, + "cpu.throttled_time": 47.0, "cpu.util": 5.4, "cpu.vcpus": 2.0, "disk.limit": 250000000000, |