heesung-sn commented on code in PR #17820:
URL: https://github.com/apache/pulsar/pull/17820#discussion_r981497137


##########
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:
   
   I see the issue is that,  if `cfs_quota_us` is -1, then we set the cpu limit 
based on the JVM, but still get the cpu usage from the cgroup usage sys files.
   
   ```
   private double getTotalCpuUsage(double elapsedTimeSeconds) {
           if (isCGroupsEnabled) {
               return getTotalCpuUsageForCGroup(elapsedTimeSeconds);
           } else {
               return getTotalCpuUsageForEntireHost();
           }
       }
   ```
   
   
   
   So please put the error message when setting the jvm limit. Ideally, I think 
we should never use jvm limit or get the cpu usage from the jvm to match.
   ```
   // Fallback to JVM reported CPU quota
           return 100 * Runtime.getRuntime().availableProcessors();
   ```
   
   From my understanding, `cfs_quota_us` is -1 means there are no CPU time 
restrictions, which means all "effective" cpus can be used. 
   
   but I am worried that if the cgroup happens to hit smaller sets cpus at that 
time, then `cpuCount` here could be less than what the cgroup actually 
configured(effective cpus).
   
   
   should we rely on cpuset (effective cpus) instead for  `cpuCount` ?
   `cpuset.cpus` or `cpuset.cpus.effective`
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to