File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -186,5 +186,23 @@ Run 'ipfs swarm limit all' to see the resulting limits.
186
186
187
187
defaultLimitConfig := scalingLimitConfig .Scale (int64 (maxMemory ), int (numFD ))
188
188
189
+ // Simple checks to overide autoscaling ensuring limits make sense versus the connmgr values.
190
+ // There are ways to break this, but this should catch most problems already.
191
+ // We might improve this in the future.
192
+ // See: https://github.com/ipfs/kubo/issues/9545
193
+ if cfg .ConnMgr .Type == nil || cfg .ConnMgr .Type .String () != "none" {
194
+ maxInboundConns := int64 (defaultLimitConfig .System .ConnsInbound )
195
+ if connmgrHighWaterTimesTwo := cfg .ConnMgr .HighWater .WithDefault (config .DefaultConnMgrHighWater ) * 2 ; maxInboundConns < connmgrHighWaterTimesTwo {
196
+ maxInboundConns = connmgrHighWaterTimesTwo
197
+ }
198
+ // MAGIC: 800 is probably a good enough number to be a good network citizen.
199
+ if maxInboundConns < 800 {
200
+ maxInboundConns = 800
201
+ }
202
+ // Set StreamsInbound to maxInboundConns * (ConnsInbound / StreamsInbound) while avoid truncating.
203
+ defaultLimitConfig .System .StreamsInbound = int (maxInboundConns * int64 (defaultLimitConfig .System .StreamsInbound ) / int64 (defaultLimitConfig .System .ConnsInbound ))
204
+ defaultLimitConfig .System .ConnsInbound = int (maxInboundConns )
205
+ }
206
+
189
207
return defaultLimitConfig , nil
190
208
}
You can’t perform that action at this time.
0 commit comments