0xffff-zhiyan commented on code in PR #20481:
URL: https://github.com/apache/kafka/pull/20481#discussion_r2438138119


##########
core/src/main/scala/kafka/server/KafkaRequestHandler.scala:
##########
@@ -112,7 +114,10 @@ class KafkaRequestHandler(
       val req = requestChannel.receiveRequest(300)
       val endTime = time.nanoseconds
       val idleTime = endTime - startSelectTime
-      aggregateIdleMeter.mark(idleTime / totalHandlerThreads.get)
+      // Per-pool idle ratio uses the pool's own thread count as denominator
+      perPoolIdleMeter.mark(idleTime / poolHandlerThreads.get)
+      // Aggregate idle ratio uses the total threads across all pools as 
denominator
+      aggregateIdleMeter.mark(idleTime / aggregateThreads.get)

Review Comment:
   The `aggregateThreads` must be defined in a singleton object because all 
pool instances need to increment/decrement the exact same AtomicInteger 
instance, whereas `aggregateIdleMeter` can be instance-specific because each 
pool creates its own Meter that reports to the same metric name, and the 
metrics registry automatically aggregates data from meters with identical names.
   
   passing aggregateThreads through the constructor would require manually 
ensuring all pools receive the same reference, while the singleton pattern 
guarantees this by design.



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