|
| 1 | +<!-- |
| 2 | +* Copyright (c) 2017, 2024 IBM Corp. and others |
| 3 | +* |
| 4 | +* This program and the accompanying materials are made |
| 5 | +* available under the terms of the Eclipse Public License 2.0 |
| 6 | +* which accompanies this distribution and is available at |
| 7 | +* https://www.eclipse.org/legal/epl-2.0/ or the Apache |
| 8 | +* License, Version 2.0 which accompanies this distribution and |
| 9 | +* is available at https://www.apache.org/licenses/LICENSE-2.0. |
| 10 | +* |
| 11 | +* This Source Code may also be made available under the |
| 12 | +* following Secondary Licenses when the conditions for such |
| 13 | +* availability set forth in the Eclipse Public License, v. 2.0 |
| 14 | +* are satisfied: GNU General Public License, version 2 with |
| 15 | +* the GNU Classpath Exception [1] and GNU General Public |
| 16 | +* License, version 2 with the OpenJDK Assembly Exception [2]. |
| 17 | +* |
| 18 | +* [1] https://www.gnu.org/software/classpath/license.html |
| 19 | +* [2] https://openjdk.org/legal/assembly-exception.html |
| 20 | +* |
| 21 | +* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 |
| 22 | +--> |
| 23 | + |
| 24 | +# -XX:[+|-]CpuLoadCompatibility |
| 25 | + |
| 26 | +This option enables or disables the OpenJDK behavior of the `getProcessCpuLoad()` and `getSystemCpuLoad()` methods in OpenJ9. |
| 27 | + |
| 28 | +## Syntax |
| 29 | + |
| 30 | + -XX:[+|-]CpuLoadCompatibility |
| 31 | + |
| 32 | +| Setting | Effect | Default | |
| 33 | +|-----------------------|---------|:----------------------------------------------------------------------------------:| |
| 34 | +| `-XX:+CpuLoadCompatibility` | Enable | :fontawesome-solid-check:{: .yes aria-hidden="true"}<span class="sr-only">yes</span> | |
| 35 | +| `-XX:-CpuLoadCompatibility` | Disable | | |
| 36 | + |
| 37 | +## Explanation |
| 38 | + |
| 39 | +The `getProcessCpuLoad()` method in the `com.sun.management.OperatingSystemMXBean` class returns the recent CPU usage value for the Java virtual machine process, while the `getSystemCpuLoad()` method returns the recent CPU usage value for the whole system. When these methods were called in OpenJ9 for the first time, these methods were returning `-1` to indicate that the recent CPU usage is not available. It was difficult to identify whether the reason for the `-1` value was an error or because the call was the first call and therefore, no recent CPU usage was available. |
| 40 | + |
| 41 | +In OpenJDK, these methods return `0` value in the case of the first call, which makes it easier to differentiate between the first call behavior and an error that needs further investigation. |
| 42 | + |
| 43 | +The `-XX:+CpuLoadCompatibility` option is used to enable the OpenJDK behavior of the `getProcessCpuLoad()` and `getSystemCpuLoad()` methods in OpenJ9. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +<!-- ==== END OF TOPIC ==== xxcpuloadcompatibility.md ==== --> |
0 commit comments