You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/27 01:40:38 UTC

[GitHub] [pulsar] thetumbled commented on a diff in pull request #17820: [Bugfix] [LinuxInfoUtils] incorrect CPU usage collected by pulsar #17815

thetumbled commented on code in PR #17820:
URL: https://github.com/apache/pulsar/pull/17820#discussion_r980648364


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LinuxInfoUtils.java:
##########
@@ -85,6 +86,8 @@ public static double getTotalCpuLimit(boolean isCGroupsEnabled) {
                 if (quota > 0) {
                     return 100.0 * quota / period;
                 }
+                int cpuCount = readTrimStringFromFile(Paths.get(CGROUPS_CPU_USAGE_PER_CPU_PATH)).split(" ").length;

Review Comment:
   ```
   - cpuacct.usage_percpu
   reports the CPU time (in nanoseconds) consumed on each CPU by all tasks in this cgroup (including tasks lower in the hierarchy).
   - cpuacct.usage
   reports the total CPU time (in nanoseconds) consumed by all tasks in this cgroup (including tasks lower in the hierarchy).
   ```
   https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/sec-cpuacct
   
   The sum of the values in cpuacct.usage_percpu is equal to the value in cpuacct.usage,and we have calculated the cpu usage base on cpuacct.usage. Using cpuacct.usage_percpu to calculate cpu limit can ensure that the highest cpu usage is 100%.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org