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

Add random delay to periodic peer update thread #1277

Merged
merged 3 commits into from Sep 16, 2021

Conversation

jordanschalm
Copy link
Member

@jordanschalm jordanschalm commented Sep 10, 2021

We are observing synchronized goroutine spikes causing consensus finalization issues on large committees on benchnet, with the same period as this peer update process.

This PR:

  • Adds a uniform random delay to the initial launch of the peer update requesting routine, so that peer updates are not synchronized across the network
  • Updates engine.Unit to exit goroutines launched with LaunchPeriodically immediately, even if they are waiting for the initial delay period when the unit is torn down

Run on Benchnet without this fix:
Screen Shot 2021-09-10 at 6 43 25 PM

With this fix:
Screen Shot 2021-09-10 at 6 43 34 PM

We are observing synchronized goroutine spikes causing consensus
finalization issues on large committees on benchet, with the same period
as this peer update process. This adds a random delay before spawning
the thread which requests updates, so that updates are not synchronised.
@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2021

Codecov Report

Merging #1277 (e7f9d37) into master (0a8729c) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1277      +/-   ##
==========================================
- Coverage   54.59%   54.57%   -0.03%     
==========================================
  Files         498      498              
  Lines       31533    31537       +4     
==========================================
- Hits        17217    17212       -5     
- Misses      11968    11977       +9     
  Partials     2348     2348              
Flag Coverage Δ
unittests 54.57% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
engine/unit.go 66.66% <100.00%> (+1.96%) ⬆️
network/p2p/peerManager.go 71.05% <100.00%> (+0.78%) ⬆️
...sus/approvals/assignment_collector_statemachine.go 40.38% <0.00%> (-6.74%) ⬇️
engine/collection/synchronization/engine.go 62.90% <0.00%> (-1.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a8729c...e7f9d37. Read the comment docs.

Comment on lines +94 to +95
delay := time.Duration(mrand.Int63n(pm.peerUpdateInterval.Nanoseconds()))
pm.unit.LaunchPeriodically(pm.RequestPeerUpdate, pm.peerUpdateInterval, delay)
Copy link
Contributor

Choose a reason for hiding this comment

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

This delay becomes a static configuration parameter of the update loop of the node when inserted here.

Would it be possible to instead choose the delay as part of each run through the loop? That way a node isn't "stuck" with a long delay.

Copy link
Member Author

Choose a reason for hiding this comment

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

The delay only happens once (here), before the static-period ticker starts. The time between each peer update is still 10m, it's just the time before the first peer update that can have a longer delay.

Copy link
Contributor

Choose a reason for hiding this comment

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

😲 got it!

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.

TYVM!

Comment on lines +94 to +95
delay := time.Duration(mrand.Int63n(pm.peerUpdateInterval.Nanoseconds()))
pm.unit.LaunchPeriodically(pm.RequestPeerUpdate, pm.peerUpdateInterval, delay)
Copy link
Contributor

Choose a reason for hiding this comment

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

😲 got it!

@jordanschalm
Copy link
Member Author

bors merge

@bors
Copy link
Contributor

bors bot commented Sep 16, 2021

@bors bors bot merged commit 56e18b5 into master Sep 16, 2021
@bors bors bot deleted the jordan/5838-peer-pruning-jitter branch September 16, 2021 15:11
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.

None yet

4 participants