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

Fix for network discovery state machine spin loop #2378

Merged

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Oct 23, 2020

Description

If the node is unable to obtain many peers it continues to aggresively
ask for peers. On a small localhost network this can cause high CPU
usage as it repeatedly queries for peers in a state loop. This fix adds
checks in the Ready state that allow a transition to Idle if: there
are no sync peers, there are no sync peers other than the ones used last
time, or there have been 10 rounds in a row where the node has not been
able to obtain "enough" peers to enter "on connect" mode.

Motivation and Context

Bug fix

How Has This Been Tested?

Tested on the 2 node network in PR #2358 - CPU usage returns to normal.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Feature refactor (No new feature or functional changes, but performance or technical debt improvements)
  • New Tests
  • Documentation

Checklist:

  • I'm merging against the development branch.
  • I ran cargo-fmt --all before pushing.
  • I ran cargo test successfully before submitting my PR.
  • I have squashed my commits into a single commit.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

If the node is unable to obtain many peers it continues to aggresively
ask for peers. On a small localhost network this can cause high CPU
usage as it repeatedly queries for peers in a state loop. This fix adds
checks in the `Ready` state that allow a transition to `Idle` if: there
are no sync peers, there are no sync peers other than the ones used last
time, or there have been 10 rounds in a row where the node has not been
able to obtain "enough" peers to enter "on connect" mode.
@sdbondi sdbondi force-pushed the sb-dht-network-discovery-fix branch from 8e6318b to 6a8f7eb Compare October 23, 2020 12:03
Copy link
Collaborator

@stringhandler stringhandler left a comment

Choose a reason for hiding this comment

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

Good catch

@stringhandler stringhandler merged commit a495c98 into tari-project:development Oct 23, 2020
@sdbondi sdbondi deleted the sb-dht-network-discovery-fix branch October 23, 2020 12:52
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

2 participants