Skip to content

Commit

Permalink
adjust conns to 2x maxconns for duplicate connections
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Mar 15, 2022
1 parent 53c525f commit 9fcafff
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions node/modules/lp2p/rcmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ func ResourceManager(connMgrHi uint) func(lc fx.Lifecycle, repo repo.LockedRepo)
// - if maxconns are too high, adjust Conn/FD/Stream limits
defaultLimits := rcmgr.DefaultLimits.WithSystemMemory(.125, 1<<30, 4<<30)
maxconns := int(connMgrHi)
if maxconns > defaultLimits.SystemBaseLimit.ConnsInbound {
defaultLimits.SystemBaseLimit.ConnsInbound = logScale(maxconns)
defaultLimits.SystemBaseLimit.ConnsOutbound = logScale(maxconns)
defaultLimits.SystemBaseLimit.Conns = logScale(2 * maxconns)
if 2*maxconns > defaultLimits.SystemBaseLimit.ConnsInbound {
// adjust conns to 2x to allow for two conns per peer (TCP+QUIC)
defaultLimits.SystemBaseLimit.ConnsInbound = logScale(2 * maxconns)
defaultLimits.SystemBaseLimit.ConnsOutbound = logScale(2 * maxconns)
defaultLimits.SystemBaseLimit.Conns = logScale(4 * maxconns)

defaultLimits.SystemBaseLimit.StreamsInbound = logScale(16 * maxconns)
defaultLimits.SystemBaseLimit.StreamsOutbound = logScale(64 * maxconns)
defaultLimits.SystemBaseLimit.Streams = logScale(64 * maxconns)

if maxconns > defaultLimits.SystemBaseLimit.FD {
defaultLimits.SystemBaseLimit.FD = logScale(maxconns)
if 2*maxconns > defaultLimits.SystemBaseLimit.FD {
defaultLimits.SystemBaseLimit.FD = logScale(2 * maxconns)
}

defaultLimits.ServiceBaseLimit.StreamsInbound = logScale(8 * maxconns)
Expand Down

0 comments on commit 9fcafff

Please sign in to comment.