Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8197589

Update CPU count algorithm when both cpu shares and quotas are used

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 10
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
    • Environment:

      Docker container

    • Subcomponent:
    • Resolved In Build:
      b03
    • CPU:
      x86
    • OS:
      linux
    • Verification:
      Verified

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bobv Bob Vandette
                Reporter:
                bobv Bob Vandette
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: