-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(discovery): Implement capped linear backoff and asynchronous tri… #2766
Conversation
…ggering This commit introduces two significant changes to the discoveryLoop function in the discovery package. First, we have implemented a capped linear backoff mechanism to reduce the frequency of retries during the discovery process. The backoff starts at 5 seconds and increases by a factor of 5, capped at a maximum duration of 10 minutes. This helps reduce CPU and network load and improves the efficiency of peer discovery. Second, we have added asynchronous triggering of the discoveryLoop using the triggerDisc channel. This change reduces wasted cycles by triggering the discovery process only when necessary, rather than at a fixed interval. Additionally, we have introduced two new constants, backoffInitialDuration and maxBackoffDuration, to control the backoff behavior.
Codecov Report
@@ Coverage Diff @@
## main #2766 +/- ##
==========================================
+ Coverage 51.92% 51.98% +0.06%
==========================================
Files 161 161
Lines 10827 10831 +4
==========================================
+ Hits 5622 5631 +9
+ Misses 4710 4705 -5
Partials 495 495
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nodersteam i think baking the backoff into the ticker is the wrong approach. I'd also request splitting the two tasks (backoff, async trigger) into two PRs for ease of review if you can.
For the backoff, i'd suggest something like adding a "backoffDuration" time.Interval to the Discover struct (or even something that wraps that to apply a backoff) then leave the tick interval the same, but add/update an incrementing backup duration on d.discover failures that will be checked before executing. Will make things simpler. Also, i'd suggest adding a little jitter to the backoff interval so very slightly randomize the backoff times. Want to give it a shot?
yes, I will try to implement this |
@nodersteam i quite like the idea of being able to see some more detailed logging if the |
…s updated, fixed skipping rollback in case, changed time.Timer, fixed running only anonymous function
Implemented a capped linear backoff mechanism to reduce the frequency of retries during the discovery process. The backoff starts at 5 seconds and increases by a factor of 5, capped at a maximum duration of 10 minutes.
Added asynchronous triggering of the discoveryLoop using the triggerDisc channel
#2703