chennaji9 opened a new issue, #11321:
URL: https://github.com/apache/rocketmq/issues/11321
### Description
`StatisticsBrief.getTPValue` scans the histogram buckets from the highest
down to find the percentile bucket, but the loop condition excludes bucket 0:
```java
//
common/src/main/java/org/apache/rocketmq/common/statistics/StatisticsBrief.java:115
int tmp = 0;
for (int i = counts.length - 1; i > 0; i--) {
tmp += counts[i].get();
if (tmp > excludes) {
return Math.min(getSlotTPValue(i), getMax());
}
}
return 0;
```
When all (or enough) samples fall into the first bucket, the scan never
accumulates more than `excludes` and the method falls through to `return 0` — a
percentile of 0 for a non-empty, non-zero sample set.
Reproduction with the meta `{{100, 10}}` (range [0,100), 10 slots): sample
the value `5` one hundred times. `getMax()` is 5, but `getTPValue(0.99f)` and
`tp999()` return **0**, because every sample lands in bucket 0 (`(5 - 0) / 10
== 0`), which the loop never visits.
`StatisticsBrief` backs `StatisticsBriefInterceptor` / `StatisticsManager`
percentile output (e.g. TP999 printed by
`StatisticsItemScheduledIncrementPrinter`), so any metric whose whole
population sits in the first latency bucket reports a zero percentile.
### Expected behavior
The traversal should include bucket 0, i.e. loop while `i >= 0`; a sample
set contained in the first bucket then yields `min(slot-0 upper bound, max)`
instead of 0.
--
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]