Created
June 29, 2022 23:22
-
-
Save ivy/dc1e5572a51a42cfa54f4a2b75b38fed to your computer and use it in GitHub Desktop.
Revisions
-
ivy created this gist
Jun 29, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ # | Next retry backoff | Total waiting time ------------------------------------------- 1 | 0d 0h 0m 20s | 0d 0h 0m 20s 2 | 0d 0h 0m 26s | 0d 0h 0m 46s 3 | 0d 0h 0m 46s | 0d 0h 1m 32s 4 | 0d 0h 1m 56s | 0d 0h 3m 28s 5 | 0d 0h 4m 56s | 0d 0h 8m 24s 6 | 0d 0h 11m 10s | 0d 0h 19m 34s 7 | 0d 0h 22m 26s | 0d 0h 42m 0s 8 | 0d 0h 40m 56s | 0d 1h 22m 56s 9 | 0d 1h 9m 16s | 0d 2h 32m 12s 10 | 0d 1h 50m 26s | 0d 4h 22m 38s 11 | 0d 2h 47m 50s | 0d 7h 10m 28s 12 | 0d 4h 5m 16s | 0d 11h 15m 44s 13 | 0d 5h 46m 56s | 0d 17h 2m 40s 14 | 0d 7h 57m 26s | 1d 1h 0m 6s 15 | 0d 10h 41m 46s | 1d 11h 41m 52s 16 | 0d 14h 5m 20s | 2d 1h 47m 12s 17 | 0d 18h 13m 56s | 2d 20h 1m 8s 18 | 0d 23h 13m 46s | 3d 19h 14m 54s 19 | 1d 5h 11m 26s | 5d 0h 26m 20s 20 | 1d 12h 13m 56s | 6d 12h 40m 16s 21 | 1d 20h 28m 40s | 8d 9h 8m 56s 22 | 2d 6h 3m 26s | 10d 15h 12m 22s 23 | 2d 17h 6m 26s | 13d 8h 18m 48s 24 | 3d 5h 46m 16s | 16d 14h 5m 4s 25 | 3d 20h 11m 56s | 20d 10h 17m 0s This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/usr/bin/env ruby def rand(max) max / 2 end # From: https://github.com/mperham/sidekiq/blob/8e3dd2e6e898869b5026a76d2e01634737f41744/lib/sidekiq/job_retry.rb#L219-L226 def delay_for(jobinst, count, exception) jitter = rand(10) * (count + 1) if jobinst&.sidekiq_retry_in_block custom_retry_in = retry_in(jobinst, count, exception).to_i return custom_retry_in + jitter if custom_retry_in > 0 end (count**4) + 15 + jitter end def format_duration(i) days = i / 86400 hours = i / 3600 % 24 minutes = i / 60 % 60 seconds = i % 60 "#{days}d #{hours}h #{minutes}m #{seconds}s" end 0.upto(24).each do |i| new_delay = delay_for(nil, i, nil) previous_delay = i.downto(0).map { |j| delay_for(nil, j, nil) }.sum puts "#{(i + 1).to_s.rjust(2)} | #{format_duration(new_delay).rjust(18)} | #{format_duration(previous_delay).rjust(18)}" end