Skip to content

Commit

Permalink
Merge pull request #4656 from karknu/karknu/churn_20_m
Browse files Browse the repository at this point in the history
Be less aggresive when churning peers
  • Loading branch information
coot authored Aug 24, 2023
2 parents f54839c + 7b697fd commit a9ca17b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
10 changes: 9 additions & 1 deletion ouroboros-network/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@

### Breaking changes

- Removes `updatePeerSharing` from `KnownPeers` module API
### Non-breaking changes

* Less aggresive churning of established and known peers.

## 0.9.1.0 -- 2023-08-22

### Breaking changes

* Removes `updatePeerSharing` from `KnownPeers` module API

### Non-breaking changes

Expand Down
21 changes: 14 additions & 7 deletions ouroboros-network/src/Ouroboros/Network/PeerSelection/Churn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,22 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval
-- Forget the worst performing non-active peers.
atomically $ modifyTVar peerSelectionVar (\targets -> targets {
targetNumberOfRootPeers =
decrease (targetNumberOfRootPeers base)
decrease (targetNumberOfRootPeers base - targetNumberOfEstablishedPeers base)
+ targetNumberOfEstablishedPeers base
, targetNumberOfKnownPeers =
decrease (targetNumberOfKnownPeers base)
decrease (targetNumberOfKnownPeers base - targetNumberOfEstablishedPeers base)
+ targetNumberOfEstablishedPeers base
, targetNumberOfEstablishedPeers =
decrease (targetNumberOfEstablishedPeers base)
decrease (targetNumberOfEstablishedPeers base - targetNumberOfActivePeers base)
+ targetNumberOfActivePeers base
, targetNumberOfKnownBigLedgerPeers =
decrease (targetNumberOfKnownBigLedgerPeers base)
decrease (targetNumberOfKnownBigLedgerPeers base -
targetNumberOfEstablishedBigLedgerPeers base)
+ targetNumberOfEstablishedBigLedgerPeers base
, targetNumberOfEstablishedBigLedgerPeers =
decrease (targetNumberOfEstablishedBigLedgerPeers base)
decrease (targetNumberOfEstablishedBigLedgerPeers base -
targetNumberOfActiveBigLedgerPeers base)
+ targetNumberOfActiveBigLedgerPeers base
})

-- Give the governor time to properly demote them.
Expand Down Expand Up @@ -202,9 +209,9 @@ peerChurnGovernor tracer deadlineChurnInterval bulkChurnInterval
shortDelay :: StdGen -> DiffTime -> m StdGen
shortDelay = fuzzyDelay' bulkChurnInterval 60

-- Replace 20% or at least on peer every churnInterval.
-- Replace 20% or at least one peer every churnInterval.
decrease :: Int -> Int
decrease v = v - max 1 (v `div` 5)
decrease v = max 0 $ v - max 1 (v `div` 5)



0 comments on commit a9ca17b

Please sign in to comment.