Copilot commented on code in PR #28564:
URL: https://github.com/apache/flink/pull/28564#discussion_r4496296150


##########
flink-runtime/src/main/java/org/apache/flink/runtime/metrics/util/SystemResourcesCounter.java:
##########
@@ -280,4 +310,24 @@ private void calculateNetworkUsage(List<NetworkIF> 
networkIFs) {
             bytesSentPerInterface[i] = networkIF.getBytesSent();
         }
     }
+
+    private void calculateProcessUsage() {
+        OSProcess process = operatingSystem.getProcess(processId);
+        if (process == null) {
+            return;
+        }
+        // CPU load is only available relative to a prior snapshot; report 0 
until we have one.
+        if (previousProcessSnapshot != null) {
+            // getProcessCpuLoadBetweenTicks() returns the number of cores 
used; normalize it to a
+            // percentage of the whole machine to match the semantics of 
System.CPU.Usage.
+            processCpuUsage =
+                    100d
+                            * 
process.getProcessCpuLoadBetweenTicks(previousProcessSnapshot)
+                            / logicalProcessorCount;

Review Comment:
   The new CPU and I/O assertions pass when all three values remain at their 
default zero, and the CPU assertion also misses incorrect processor-count 
normalization. Add deterministic tests with controlled process snapshots and a 
processor count greater than one, asserting the exact CPU percentage, 
initial-sample zero, and read/write byte values. Keep the real-OS check as a 
smoke test.



-- 
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