-
Bug
-
Resolution: Fixed
-
P3
-
11, 17, 21
-
b14
-
aarch64
-
os_x
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8332937 | 22.0.2 | Long Yang | P3 | Resolved | Fixed | b08 |
JDK-8327766 | 21.0.4 | Long Yang | P3 | Resolved | Fixed | b01 |
JDK-8327660 | 17.0.13 | Long Yang | P3 | Resolved | Fixed | b01 |
JDK-8327649 | na | Long Yang | P3 | Closed | Not an Issue |
java -XX:StartFlightRecording=name=test,settings=default,filename=test.jfr EatCpu 4
top
PID COMMAND %CPU (total 8 cores)
42421 java 397.1
jfr view jdk.CPULoad osx-m1.jfr
CPU Load
Time JVM User JVM System Machine Total
------------ --------------- -------------- -------------
10:51:57 0.64% 0.56% 62.59%
10:51:58 0.64% 0.56% 59.70%
10:51:59 0.64% 0.56% 59.50%
10:52:00 0.63% 0.57% 65.71%
The User and System of jdk.CPULoad on Apple M1 are inaccurate.
The system's CPU is mainly consumed by Java (see Machine Total), but both JVM User and JVM System are obviously low.
The same code, if run on OSX with Intel x64 (12 Hyper-Threading cores), the result is accurate.
jfr view jdk.CPULoad j17-x64.jfr
CPU Load
Time JVM User JVM System Machine Total
------------ --------------- --------------- -------------
10:37:54 8.39% 24.96% 34.11%
10:37:55 8.45% 24.89% 33.97%
10:37:56 8.44% 24.92% 34.22%
10:37:57 8.42% 24.91% 34.39%
The reason is JFR used task_info() with flavor TASK_ABSOLUTETIME_INFO to read User and System time.
https://github.com/openjdk/jdk/blob/f8a924a749a786f9e9172561135731c4948c9856/src/hotspot/os/bsd/os_perf_bsd.cpp#L158
task_info(task, TASK_ABSOLUTETIME_INFO, (task_info_t)task_info_data, &task_info_count)
but it is not reliable on Apple m1, see https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/tests/task_info.c#L344
A possible solution is to use TASK_THREAD_TIMES_INFO and
TASK_BASIC_INFO_64, these two flavors are reliable, just like what UnixOperatingSystem.c does.
https://github.com/openjdk/jdk/blob/2963c9e6778b95f5c0fc4298064a21d1e8f31b91/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c#L87
- backported by
-
JDK-8327660 The User and System of jdk.CPULoad on Apple M1 are inaccurate
- Resolved
-
JDK-8327766 The User and System of jdk.CPULoad on Apple M1 are inaccurate
- Resolved
-
JDK-8332937 The User and System of jdk.CPULoad on Apple M1 are inaccurate
- Resolved
-
JDK-8327649 The User and System of jdk.CPULoad on Apple M1 are inaccurate
- Closed
- links to
-
Commit openjdk/jdk17u-dev/2d834b36
-
Commit openjdk/jdk21u-dev/50f447c5
-
Commit openjdk/jdk22u/5a659b7d
-
Commit openjdk/jdk/8dbd4b39
-
Review openjdk/jdk17u-dev/2277
-
Review openjdk/jdk21u-dev/341
-
Review openjdk/jdk22u/161
-
Review openjdk/jdk/17976