feat: implement peer grief (de-prioritization) mechanism for the PeeStore#3786
Draft
fcecin wants to merge 1 commit into
Draft
feat: implement peer grief (de-prioritization) mechanism for the PeeStore#3786fcecin wants to merge 1 commit into
fcecin wants to merge 1 commit into
Conversation
|
You can find the image built from this PR at Built from 1896c92 |
Contributor
Author
|
Rebased to latest master so now the diff (Files changed tab) makes sense. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a grief points (penalty points) tracker to peers in the PeerStore.
When selecting service peers for dialing, peers are separated into timed buckets, and buckets are shuffled internally. Buckets are wide enough to allow for randomness while gradually de-prioritizing peers that get pushed into deeper buckets.
Peers move back into better buckets over time in a lazy fashion, without requiring timers to recompute grief scores and reconfigure buckets. Peers that accumulate too many grief points are excluded from selection entirely until they cool down sufficiently back into the buckets that are considered for selection.
Any behavior from a remote peer that causes grief to the local peer, but isn't grounds for terminating a connection, can invoke PeerManager.griefPeer(peer, amount) to add penalty points to that peer.
Changes
GriefBooktoPeerStoretracking per-peer grief scores with lazy cooldownGriefDatatuple stores score and cooldown timestamp; cooldown decays 1 point perGriefCooldownInterval(1 minute)griefScoreandgriefCooldownTimefields toRemotePeerInforesolveGriefScore,griefPeer,getGriefScoreprocs onPeerStorePeerManager.griefPeerhelper for use from protocol clientsshuffle()withsortByGriefScoreinselectPeersandconnectToRelayPeersGriefBucketSize = 5): peers within the same bucket are shuffled randomly, preserving load distributionMaxGriefBucket(bucket 3, score > 15) are excluded from selection entirelyPeerExchangeClientsorequest()isn't called on a nil objectIssue
iterates #3784