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/02/17 04:06:32 UTC

[GitHub] [pulsar] Jason918 commented on a change in pull request #14330: [pulsar-broker] Fix avg-messagePerEntry metrics for consumer

Jason918 commented on a change in pull request #14330:
URL: https://github.com/apache/pulsar/pull/14330#discussion_r808657756



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java
##########
@@ -282,7 +282,7 @@ public boolean readCompacted() {
 
         // calculate avg message per entry
         int tmpAvgMessagesPerEntry = AVG_MESSAGES_PER_ENTRY.get(this);
-        tmpAvgMessagesPerEntry = (int) Math.round(tmpAvgMessagesPerEntry * avgPercent
+        tmpAvgMessagesPerEntry = (int) Math.floor(tmpAvgMessagesPerEntry * avgPercent

Review comment:
       I don't think using `floor` would solve this kind of precision issue.
   Using `floor` also have problems of this value going up, e.g. `avgMessagesPerEntry` = 1 and new value is 2. The result is always 1.
   
   We should just use double type for `avgMessagesPerEntry`.




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