In containers running Java 21+, I would like to have the active processor count reflect the actual available hardware cores, regardless of configured CPU shares.
CSR JDK-8281571 "Do not use CPU Shares to compute active processor count" explains the problem with using Docker/Kubernetes CPU resource limits to determine the active processor count with -XX:+UseContainerSupport and I understand it to have changed this.
In Java 21 however, the deprecated flags controlling this (UseContainerCpuShares and PreferContainerQuotaForCPUCount) are gone, and I cannot find documentation on what the situation is supposed to be wrt container CPU limits.
The behavior in Kubernetes, with resource limits like this:
resources:
limits:
cpu: 1000m
is that the active processor count is limited to 1 with all the problems described in JDK-8281571 (Runtime.getRuntime().availableProcessors() returns 1).
I could override this explicitly with -XX:ActiveProcessorCount=n, but this requires explicitly configuring the concrete processor count, which might change with node updates and tends to be missed during updates.
I tried setting -XX:ActiveProcessorCount=-1, however this does not do anything.