summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@oath.com>2017-11-27 12:17:55 +0100
committerValerij Fredriksen <valerijf@oath.com>2017-11-27 12:17:55 +0100
commit5cc155fbac9306527b2451836ffad1ac74555046 (patch)
treee3f02392cb2e189be15c5a20c7680436a5ee1e13
parent3294fb40a3724f00ecb0d3c6daba7458a38ea347 (diff)
Rearrange calculations, fix comments. No functional changes
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java25
1 files changed, 13 insertions, 12 deletions
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 b66ef50236c..d01692f1f05 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
@@ -535,14 +535,10 @@ public class NodeAgentImpl implements NodeAgent {
lastCpuMetric.updateCpuDeltas(cpuSystemTotalTime, cpuContainerTotalTime, cpuContainerKernelTime);
- // CPU usage by a container as percentage of total host CPU, cpuPercentageOfHost, is given by dividing used
- // CPU time used by the container with CPU time used by the entire system.
- double cpuUsageRatioOfHost = lastCpuMetric.getCpuUsageRatio();
-
- // CPU usage by a container as percentage of total CPU allocated to it is given by dividing the
- // cpuPercentageOfHost with the ratio of container minCpuCores by total number of CPU cores.
- double cpuUsageRatioOfAllocated = totalNumCpuCores * cpuUsageRatioOfHost / nodeSpec.minCpuCores;
- double cpuKernelUsageRatioOfAllocated = cpuUsageRatioOfAllocated * lastCpuMetric.getCpuKernelUsageRatio();
+ // Ratio of CPU cores allocated to this container to total number of CPU cores on this host
+ final double allocatedCpuRatio = nodeSpec.minCpuCores / totalNumCpuCores;
+ double cpuUsageRatioOfAllocated = lastCpuMetric.getCpuUsageRatio() / allocatedCpuRatio;
+ double cpuKernelUsageRatioOfAllocated = lastCpuMetric.getCpuKernelUsageRatio() / allocatedCpuRatio;
long memoryTotalBytesUsed = memoryTotalBytesUsage - memoryTotalBytesCache;
double memoryUsageRatio = (double) memoryTotalBytesUsed / memoryTotalBytes;
@@ -637,13 +633,18 @@ public class NodeAgentImpl implements NodeAgent {
this.containerKernelUsage = containerKernelUsage;
}
- double getCpuKernelUsageRatio() {
- return deltaContainerUsage == 0 ? 0 : (double) deltaContainerKernelUsage / deltaContainerUsage;
- }
-
+ /**
+ * Returns the CPU usage ratio for the docker container that this NodeAgent is managing
+ * in the time between the last two times updateCpuDeltas() was called. This is calculated
+ * by dividing the CPU time used by the container with the CPU time used by the entire system.
+ */
double getCpuUsageRatio() {
return deltaSystemUsage == 0 ? 0 : (double) deltaContainerUsage / deltaSystemUsage;
}
+
+ double getCpuKernelUsageRatio() {
+ return deltaSystemUsage == 0 ? 0 : (double) deltaContainerKernelUsage / deltaSystemUsage;
+ }
}
// TODO: Also skip orchestration if we're downgrading in test/staging