Skip to content
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

Merged
merged 2 commits into from
Aug 5, 2022

Conversation

gdanezis
Copy link
Collaborator

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.

@@ -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));
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, half-max delay?

Copy link
Contributor

@huitseeker huitseeker left a 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!

  1. Can we log this periodically at DEBUG? Draw a normalized random float, log if it's less than .001 kinda thing?
  2. 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.
  3. It may be useful to call out we're doing proportional control, for the future dev looking at this.
  4. 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.

@gdanezis gdanezis merged commit 486ed2c into main Aug 5, 2022
@gdanezis gdanezis deleted the adapter-backoff branch August 5, 2022 13:26
tharbert pushed a commit that referenced this pull request Aug 5, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants