From 9fcafff847173961bd294e11670de24b0163f0e6 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 15 Mar 2022 09:59:34 +0200 Subject: [PATCH] adjust conns to 2x maxconns for duplicate connections --- node/modules/lp2p/rcmgr.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/node/modules/lp2p/rcmgr.go b/node/modules/lp2p/rcmgr.go index 24bea465f..d0906fd8f 100644 --- a/node/modules/lp2p/rcmgr.go +++ b/node/modules/lp2p/rcmgr.go @@ -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)