JDK 10 included an enhancement (https://bugs.openjdk.java.net/browse/JDK-8146115) which allowed the JVM to determine the number of processors it should use based on information extracted from the Linux cgroup file system. The algorithm used to select the number of processors was:
min(cpu shares, cpu quota/cpu period, physical cpus) *
*if cpu shares or quotas were not specified or configured, they are not included in the calculation.
This algorithm assumed that developers would select either cpu shares or quotas and not both. There are popular use cases (Kubernetes) which use both cpu shares and cpu quotas in order to provide a minimum to maximum range of cpu resource limits. Since our formula always selects the minimum, we were potentially underutilizing the host system cpu resources.
The solution is to alter the formula to provide two modes when both cpu shares and quotas are set. If the flag PreferContainerQuotaForCPUCount is set to true, take the cpu quota value, if provided, without exceeding the number of physical cpus on the system. If the flag PreferContainerQuotaForCPUCount is false, use the minimum of cpu shares or cpu quotas, if set, without exceeding the number of physical cpus in the system. If only one of cpu shares or cpu quotas is provided, then use the specified value limited by the number of physical processors in the system.