Skip to content

Commit

Permalink
fix: adjust rcmgr limits for accelerated DHT client rt refresh
Browse files Browse the repository at this point in the history
The Accelerated DHT client periodically refreshes its routing table,
including at startup, and if Resource Manager throttling causes the
client's routing table to be incomplete, then content routing may be
degraded or broken for users.

This adjusts the default limits to a level that empirically doesn't
cause Resource Manager throttling during initial DHT client
bootstrapping. Ideally the Accelerated DHT client would handle this
scenario more gracefully, but this works for now to unblock the 0.13
release.
  • Loading branch information
guseggert committed May 27, 2022
1 parent e8f1ce0 commit 83ae70d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core/node/libp2p/rcmgr_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ func adjustedDefaultLimits(cfg config.SwarmConfig) rcmgr.DefaultLimitConfig {
if cfg.ConnMgr.Type == "basic" {
maxconns := cfg.ConnMgr.HighWater
if 2*maxconns > defaultLimits.SystemBaseLimit.ConnsInbound {
// adjust conns to 2x to allow for two conns per peer (TCP+QUIC)
// Conns should be at least 2x larger than the high water to allow for two conns per peer (TCP+QUIC).
//
// Outbound conns are set very high to allow for the accelerated DHT client to refresh its routing table.
// Currently it does not gracefully handle RM throttling, once it does we can lower this.
defaultLimits.SystemBaseLimit.ConnsInbound = logScale(2 * maxconns)
defaultLimits.SystemBaseLimit.ConnsOutbound = logScale(2 * maxconns)
defaultLimits.SystemBaseLimit.Conns = logScale(4 * maxconns)
defaultLimits.SystemBaseLimit.ConnsOutbound = logScale(64 * maxconns)
defaultLimits.SystemBaseLimit.Conns = defaultLimits.SystemBaseLimit.ConnsOutbound + defaultLimits.SystemBaseLimit.ConnsInbound

defaultLimits.SystemBaseLimit.StreamsInbound = logScale(16 * maxconns)
defaultLimits.SystemBaseLimit.StreamsOutbound = logScale(64 * maxconns)
defaultLimits.SystemBaseLimit.Streams = logScale(64 * maxconns)
defaultLimits.SystemBaseLimit.StreamsInbound = defaultLimits.SystemBaseLimit.ConnsInbound * 4
defaultLimits.SystemBaseLimit.StreamsOutbound = defaultLimits.SystemBaseLimit.ConnsOutbound * 16
defaultLimits.SystemBaseLimit.Streams = defaultLimits.SystemBaseLimit.Conns * 16

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

0 comments on commit 83ae70d

Please sign in to comment.