-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[narwhal adpater] Add backoff mechanism to consensus adapter #3548
Conversation
@@ -178,14 +189,34 @@ impl ConsensusAdapter { | |||
// certificate will be sequenced. So the best we can do is to set a timer and notify the | |||
// client to retry if we timeout without hearing back from consensus (this module does not | |||
// handle retries). The best timeout value depends on the consensus protocol. | |||
match timeout(self.max_delay, waiter.wait_for_result()).await { | |||
let back_off_delay = | |||
self.max_delay + Duration::from_millis(self.delay_ms.load(Ordering::Relaxed)); |
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.
should we rename max_delay
to min_delay
?
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.
Or, half-max delay?
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.
The PR is great on direction!
- Can we log this periodically at DEBUG? Draw a normalized random float, log if it's less than .001 kinda thing?
- This contains magic constants, in particular the 1/2 value for the proportional gain. I would encourage you to declare it as such in a visible way, one that stands out from the computational detail of using hundreds.
- It may be useful to call out we're doing proportional control, for the future dev looking at this.
- Nit: It would be good to document on the
max_delay
field that it will be involved in clamping the delay variable after each adjustment.
34650c8
to
e46d7e5
Compare
* Add back-off mechanism to consensus adopter (both certs and fragments) * Added more clear constants and function Co-authored-by: George Danezis <george@danez.is>
We add a mechanism to estimate the average delay in consensus (using a weighted average with weight 1/2 is the last sequenced message / timeout) and then adapt the time we wait for a message to get sequenced to be the average delay + the max delay (instead of just the max delay). This avoids the churn of constant timeouts + re-submissions at times when consensus is already slow.