Github user wangli1426 commented on the pull request:

    https://github.com/apache/storm/pull/716#issuecomment-138027523
  
    Hi @HeartSaVioR, 
    
    I am glad to explain the mechanism of RateTracker as follows.
    
    In general, RateTracker provides a way to monitor the rate of certain 
event. We notify RateTracker upon the occurrence of the event by calling 
```notify()``` method, and call ```reportRate``` to retrieve the instantaneous 
rate of the event. 
    
    The rate is calculated as ```counts of occurrence``` /  ```time```. As 
RateTracker reports instantaneous rate, it only maintains the counts of 
occurrences within a given period of time as specified by 
```validTimeWindowInMils```. This is implemented by dividing the  
```validTimeWindowInMils``` into ```numOfSlides``` time slides and employing a 
timer to periodically (every ```validTimeWindowInMils```/ ```numOfSlides``` 
milliseconds) clean the count in the oldest time slide.
    
    Finally, RateTracker is very efficient. First, ```notify()``` only does 
addition on a count and thus can be finished within few CPU cycles. Second, the 
update of the counts is also light-weight and only happens periodically, e.g., 
every 1 or 2 seconds. Third, all the instances of RateTracker share the same 
timer, avoiding using too many threads.
    
    If you have further question, please let me know.
    
    Thanks.
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to