emitskevich-blp opened a new pull request, #15889:
URL: https://github.com/apache/kafka/pull/15889

   `Rate` metric reports value in the form of `sumOrCount`/`timePeriod`. It has 
a bug in `timePeriod` calculation, which leads to spikes in result values (see 
real example: `io-wait-ratio` metric has ~100% -> ~50% spikes):
   <img width="1119" alt="Screenshot 2024-05-07 at 10 10 33 PM" 
src="https://github.com/apache/kafka/assets/135832807/24800c04-b754-4c60-891d-5174823890dd";>
   
   `timePeriod` consists of several time windows (see 
[SampledStat](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/metrics/stats/SampledStat.java)
 for ref). Time window ends after a fixed time following the first event. New 
window starts by the next event after prev window end. There is always some gap 
between windows, while no event is reported. 
   
   Before reporting value, `Rate` purges (`sumOrCount := 0`) all windows, 
started before configured interval. However, it’s only reflected in numerator. 
Denominator is always the whole interval.
   
   Consider the picture, corresponding to default config (`numWindows = 2`):
   <img width="932" alt="Screenshot 2024-05-07 at 9 48 26 PM" 
src="https://github.com/apache/kafka/assets/135832807/b5d2bebb-b158-4489-a490-0910c5c460f4";>
   
   
   When report is requested (`measure()`) at the end of right window, the left 
window is purged for numerator, but not for denominator. It is the reason for 
spikes on the chart above: when we move to such zone, numerator is reduced by 2 
times, while denominator remains the same.
   
   This PR fixes such behavior. Now, if some window is purged for numerator, it 
reduces denominator as well.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to