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

OperatingSystemImpl.getCpuLoad() returns incorrect CPU load inside a container

    XMLWordPrintable

    Details

      Backports

        Description

        Created on behalf of albert.th@alibaba-inc.com
        ------

        OperatingSystemImpl.getCpuLoad() may return 1.0 in a container, even though the CPU load is obviously below 100%.

        We created a 5-core container and run 4 "while (true)" loops in the container. OperatingSystemImpl.getCpuLoad() returned 1.0, which is incorrect (0.8 is correct).
        "systemLoad" in getCpuLoad() is exactly 4.0 before "systemLoad = Math.min(1.0, systemLoad);". The problem is caused by using the elapsed time (specified by "cpu.cfs_period_us") instead of the total CPU time (specified by "cpu.cfs_quota_us"). Therefore, it is more reasonable to divide cpu usage time by "quotaNanos" instead of "elapsedNanos".

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                sgehwolf Severin Gehwolf
                Reporter:
                yyang Yi Yang
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: