On Wed, 5 May 2021 05:57:55 GMT, Hao Tang <github.com+7947546+tanghaot...@openjdk.org> wrote:
>> src/jdk.management/unix/classes/com/sun/management/internal/OperatingSystemImpl.java >> line 142: >> >>> 140: long usageNanos = containerMetrics.getCpuUsage(); >>> 141: if (numPeriods > 0 && usageNanos > 0) { >>> 142: long quotaNanos = >>> TimeUnit.MICROSECONDS.toNanos(quota * numPeriods); >> >> We happened to hit an exactly similar problem when running on a container >> with openjdk15. >> >> Given we effectively agree that the problem is `elapsedNanos` doesn't >> accurately reflect the cpu time allocated across all shares vs a single >> share, my proposal was to use `getCpuShares` as a multiplier for >> `periodLength` above. >> Is there a good reason `getCpuQuota` is a better alternative? > > Hi Argha, thanks a lot for your suggestion. I think both "quota" and "share" > are worth considering. Let us look into the implementation of > `CgroupSubsystem::active_processor_count()` in OpenJDK HotSpot > (https://github.com/openjdk/jdk/blob/master/src/hotspot/os/linux/cgroupSubsystem_linux.cpp). Thanks for linking that. It sounds reasonable to me to prefer `quota` in that case. ------------- PR: https://git.openjdk.java.net/jdk/pull/3656