-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jameinel/jitter-cleanup
#12 The original implementation of jitter computed the new delay, and then did a range of actual delay in the range of 0-100% of that value. On average, that actually means that we delay 1/2 as long as the desired values. In practice it was slightly more, because we then capped to min and max, which meant for the simple tests it was a 60% bias. The new algorithm does a +/- 20% logic, which means that on average, we actually end up very close to the expected values (my averaging ratios normally came out within 1% of the expected values, and worse case was about a 3.6% bias). Since it is random, it could be anything (you could have a string of 100 minimum possible values). But that is unlikely enough that I'll leave the test suite as asserting we are within 10% and live with the 1 in 1 billion chance that it fails. Also, there was a flaky test (StopChannel) where it could get an extra trigger sometimes, and we had the bug that if a user incorrectly supplied a exponential backoff that was <1.0 we would actually end up going below minDelay, rather than capping it at min. (we would check if you applied jitter, but not normally). There isn't a lot to QA manually, as I think the test cases are pretty thorough. I'm a bit unhappy about my "1ms" limits on the 20% over and under, but I think that is still ok. Certainly it is ok in practice.
- Loading branch information
Showing
3 changed files
with
110 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters