max randomization factor can be 1, refactor randomization function #2109
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR: Nice to have but not important, this could have impacts on code that expects values returned from an interval function to be greater than zero.
This PR proposes two changes:
+1
and to specify its contract.Randomization factor to be 1.0
Largely cosmetic, however it does have the consequence of allowing interval functions to now return 0. I don't know enough about the rest of the codebase outside of Retry to know if this will have any negative consequences. If this is accepted I would also propose a new constructor
ofExponentialFullRandomBackoff
that defaults to a value of 1.0 for randomization. Full random or full jitter is generally a desirable characteristic for backoff functions: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/Refactor randomize()
Randomize currently includes a
+ 1
which seems out of place. This +1 has no effect on large intervals since it extends the range by an insignificant amount and when the interval is 0 it forces therandomize
function to produce values between 0 and 1.My proposal is to refactor randomize so that it produces values between
0.0 <= x < 2 * current
.