-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime.availableProcessors() ignores cgroup limits #1166
Comments
@ashu-mehra @dinogun fyi |
In addition to Runtime.availableProcessors(), it appears Hotspot has also updated JVMTI API GetAvailableProcessors() to return same value as Runtime.availableProcessors().
|
OpenJDK has also added a |
Quoting statement from this bug report regarding
|
fyi - @ali-ni. Study this task/issue and investigate the VM changes required. |
fyi - @tajila |
With regards to the cgroup processor limit issue: We need to consider that cgroup limiting of The With this in mind: Another option is to write a whole new port library function in omrsysinfo.c that checks the cgroup cpu subsystem limit. Both a new flag for the existing function and a new function can be intentionally used wherever needed without affecting any other part of the VM. |
I am in favour of this approach |
Which functions would be updated to read the new CPU type? What would the type be and how would we document when to use it vs online / bound /etc? |
The type would be of an "equivalent number of CPUs", and could be labelled
|
Alternatively |
What will this option report when the JVM is not running in a docker environment? |
If this option is being defined entirely based on cgroup CFS scheduling constraints, we should return the equivalent number of CPUs based on the cgroup cpu subsystem parameters, regardless of whether or not it is fully containerized (i.e. in Docker). If this is done, however, manually running the JVM in a cgroup with these parameters defined would similarly affect what is returned. If it is running in an environment that does not support cgroups, an error can be thrown, or it could return |
I think providing a reasonable fallback would be more ideal than returning an error. Currently, According to the docs, ENTITLED: is the number of CPUs that the user has specified. This is probably what One approach is to create a "container aware" version of Also, is docker numa aware? What happens if options like |
I think changes for |
This will certainly change the number of GC threads. I have run some benchmarks to understand the impact of changing GC threads but the results are not conclusive enough. I am checking with Dmitri and Aleks to decide if we want to tune GC threads or not. |
It should be noted that while the JIT always creates 7 compilation threads they may not all be used. On Linux a non-root user cannot raise the priority of a thread. Hence, it is possible that compilation threads are starved by the presence of many application threads. The JIT has some logic to detect starvation and then it will launch additional compilation threads as needed. |
Thanks @ashu-mehra, I wasn't aware of the Is it safe to assume that if container support is disabled (ie. |
Right, if you use We have added this option in OpenJ9 but it is only being used for enabling container awareness with respect to memory limits. Relevant PRs: |
So it appears JIT is makes a new compilation thread active only when there is requirement which depends on multiple factors such as number of active threads, compilation backlog, compilation thread starvation. |
I agree that that all we need to do is to have getNumTargetCPUs take into the consideration the CPU quota. |
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. Since this functionality fulfills the needs that were previously satisfied by the `OMRPORT_CPU_ENTITLED` type, this change also removes entitled CPU count altogether. Active CPUs is now the only CPU count specified by the user. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. Since this functionality fulfills the needs that were previously satisfied by the `OMRPORT_CPU_ENTITLED` type, this change also removes entitled CPU count altogether. Active CPUs is now the only CPU count specified by the user. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. Since this functionality fulfills the needs that were previously satisfied by the `OMRPORT_CPU_ENTITLED` type, this change also removes entitled CPU count altogether. Active CPUs is now the only CPU count specified by the user. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166 Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change causes `jvmtiGetAvailableProcessors` to behave identically to `JVM_ActiveProcessorCount`, also taking into account cgroup limits when appropriate as discussed in eclipse-openj9#1166. Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. Since this functionality fulfills the needs that were previously satisfied by the `OMRPORT_CPU_ENTITLED` type, this change also removes entitled CPU count altogether. User-specified CPUs is now the only CPU count set by the user. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166. Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
This change adds functionality for overriding the number of CPUs returned by `omrsysinfo_get_number_CPUs_by_type` for the `OMRPORT_CPU_TARGET` type. This is implemented as a port library global and can be set through a port library function. Since this functionality fulfills the needs that were previously satisfied by the `OMRPORT_CPU_ENTITLED` type, this change also removes entitled CPU count altogether. User-specified CPUs is now the only CPU count set by the user. This change is to satisfy the need for this functionality, as discussed in eclipse-openj9/openj9#1166. Issue: eclipse-openj9/openj9#1166. Signed-off-by: Mohammad Ali Nikseresht <anikser@ibm.com>
@ali-ni Is this work complete? |
Cgroup cpu quota checking and |
This has gone stale. Closing |
When running OpenJ9/OpenJDK8 in Docker (e.g. via image from adoptopenjdk) a call to
Runtime.availableProcessors()
returns the amount of processors of the Docker host system and not the one defined in cgroup/sys/fs/cgroup/cpu/cpu.cfs_quota_us
.Hotspot has/had the same problem: https://bugs.openjdk.java.net/browse/JDK-6515172
which they fixed in 9 and apparently also backported to 8.
For Java 10 they add even better Docker support: https://bugs.openjdk.java.net/browse/JDK-8146115
As OpenJ9 really shines in cloud environments a better "out of the box" Docker container resource usage would be awesome.
The text was updated successfully, but these errors were encountered: