taskcluster-client: Implement randomization factor for retries

RESOLVED FIXED

Status

--
trivial
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: jonasfj, Assigned: jonasfj)

Tracking

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
We should have a randomization factor, as a percentage that can be randomly added/subtracted from the computed retry delay.

Example:
  delay is computed to 5s
  randomization factor is 0.5
  randomized delay is in [2.5; 7.5]

I doubt it's critical, but probably nice to have, and really cheap.
(Assignee)

Comment 1

3 years ago
Created attachment 8616916 [details] [review]
Github PR

Let me know if this is crazy... Thanks,

I'm aiming to do somewhat the same as you do in go..
Granted I stole this from:
http://javadoc.google-http-java-client.googlecode.com/hg/1.17.0-rc/com/google/api/client/util/ExponentialBackOff.html
And a few others that seemed to use the exact same logic.
Assignee: nobody → jopsen
Status: NEW → ASSIGNED
Attachment #8616916 - Flags: review?(pmoore)
Comment on attachment 8616916 [details] [review]
Github PR

Thanks Jonas. I double checked the maths, and all looks good!

(Math.random() - 0.5) : gives a result in [-0.5, 0.5)
=> rf * 2 * (Math.random() - 0.5) : gives a result in [-rf, +rf)
=> 1 + rf * 2 * (Math.random() - 0.5) : gives a result in [1-rf, 1+rf)
=> delay * (1 + rf * 2 * (Math.random() - 0.5)) : gives a result in [delay - delay * rf, delay + delay * rf] = adjusted delay we want

expanding: rf * 2 * (Math.random() - 0.5) = 2 * Math.random() * rf - rf gives:

adjusted delay = delay * (1 + 2 * Math.random() * rf - rf)

which is the same as the result you reached! :)
Attachment #8616916 - Flags: review?(pmoore) → review+
(Assignee)

Comment 3

3 years ago
Merged and landed in tc-client v 0.22.2
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Component: TaskCluster → General
Product: Testing → Taskcluster
Target Milestone: --- → mozilla41
Version: unspecified → Trunk
Resetting Version and Target Milestone that accidentally got changed...
Target Milestone: mozilla41 → ---
Version: Trunk → unspecified
You need to log in before you can comment on or make changes to this bug.