[
https://issues.apache.org/jira/browse/HADOOP-12356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14711899#comment-14711899
]
Yunqi Zhang commented on HADOOP-12356:
--------------------------------------
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}
> 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
> Labels: easyfix, newbie
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> The CPU usage information on Windows is computed incorrectly. The proposed
> patch fixes the issue, and unifies the the interface with Linux.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)