chennaji9 opened a new pull request, #11330:
URL: https://github.com/apache/rocketmq/pull/11330

   <!-- Please make sure the target branch is right. In most case, the target 
branch should be `develop`. -->
   
   ### Which Issue(s) This PR Fixes
   
   Fixes #11321
   
   ### Brief Description
   
   `StatisticsBrief.getTPValue` scanned the histogram buckets from the highest 
index down to `i == 1`, so bucket 0 was never considered. When the whole (or 
dominating) population falls into the first bucket — e.g. 100 samples of value 
5 with meta `{{100, 10}}` — the scan never accumulated more than `excludes` and 
fell through to `return 0`, reporting TP99/TP999 = 0 for a non-zero sample set. 
The loop now runs down to `i >= 0`, so a first-bucket population yields 
`min(slot-0 upper bound, max)` like any other bucket.
   
   `StatisticsBrief` feeds `StatisticsBriefInterceptor`/`StatisticsManager` 
percentile output, so this affected every metric whose population sat inside 
the first latency bucket.
   
   One-character production change plus a new `StatisticsBriefTest` (5 tests): 
all-samples-in-first-bucket regression, excludes==0 path, mixed low/high 
populations (both directions), and reset.
   
   ### How Did You Test This Change?
   
   `mvn -pl common -Dtest=StatisticsBriefTest test` (JDK 11, PR base commit): 
`Tests run: 5, Failures: 0, Errors: 0`.
   
   Regression proof: with the fix reverted the new test fails exactly on the 
first-bucket case (`testTpValue_allSamplesInFirstBucket` expects TP99=5, old 
code returned 0); with the fix it passes. Expected values in the other tests 
were derived by hand from the bucket arithmetic 
(`getSlotIndex`/`getSlotTPValue`).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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