Yunqi Zhang created HADOOP-12356: ------------------------------------ Summary: CPU usage statistics on Windows Key: HADOOP-12356 URL: https://issues.apache.org/jira/browse/HADOOP-12356 Project: Hadoop Common Issue Type: Bug Components: util Environment: CPU: Intel Xeon OS: Windows server Reporter: Yunqi Zhang
In {{hadoop-common/src/main/java/org/apache/hadoop/util/SysInfoWindows.java}} (in trunk), the reported CPU usage is incorrect. {code:title=SysInfoWindows.java|borderStyle=solid} // This is where we calculate all the usage information void refreshIfNeeded() { ... if (lastCumCpuTimeMs != -1) { cpuUsage = (cumulativeCpuTimeMs - lastCumCpuTimeMs) / (refreshInterval * 1.0f); } ... } {code} This {{cpuUsage}} is the cumulative CPU usage across all logical cores. For example, this number will range in [0.0, 12.0] if a server has 12 cores. Instead of reporting this raw number, we should do the following to be consistent with {{SysInfoLinux.java}}. In {{SysInfoLinux.java}}, {{cpuUsage}} ranges in [0.0, 1200.0], and the return value of {{getCpuUsage()}} ranges from [0.0, 100.0]. {code:title=SysInfoWindows.java|borderStyle=solid} // This is where we calculate all the usage information void refreshIfNeeded() { ... if (lastCumCpuTimeMs != -1) { cpuUsage = (cumulativeCpuTimeMs - lastCumCpuTimeMs) * 100F / refreshInterval; } ... } @Override public float getCpuUsage() { refreshIfNeeded(); return cpuUsage / numProcessors; } {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)