Skip to content

Commit

Permalink
add a DefaultLimitConfig with infinite limits (#41)
Browse files Browse the repository at this point in the history
This is useful when recording a trace to observe the baseline resource
consumption.
  • Loading branch information
marten-seemann authored Jun 6, 2022
1 parent 771cfe8 commit 6e563a8
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions p2p/host/resource-manager/limit_defaults.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package rcmgr

import "math"

// DefaultLimitConfig is a struct for configuring default limits.
type DefaultLimitConfig struct {
SystemBaseLimit BaseLimit
Expand Down Expand Up @@ -160,3 +162,42 @@ var DefaultLimits = DefaultLimitConfig{

StreamMemory: 16 << 20,
}

var infiniteBaseLimit = BaseLimit{
Streams: math.MaxInt,
StreamsInbound: math.MaxInt,
StreamsOutbound: math.MaxInt,
Conns: math.MaxInt,
ConnsInbound: math.MaxInt,
ConnsOutbound: math.MaxInt,
FD: math.MaxInt,
}

var infiniteMemoryLimit = MemoryLimit{
MemoryFraction: 1,
MinMemory: math.MaxInt64,
MaxMemory: math.MaxInt64,
}

// InfiniteLimits are a limiter configuration that uses infinite limits, thus effectively not limiting anything.
// Keep in mind that the operating system limits the number of file descriptors that an application can use.
var InfiniteLimits = DefaultLimitConfig{
SystemBaseLimit: infiniteBaseLimit,
SystemMemory: infiniteMemoryLimit,
TransientBaseLimit: infiniteBaseLimit,
TransientMemory: infiniteMemoryLimit,
ServiceBaseLimit: infiniteBaseLimit,
ServiceMemory: infiniteMemoryLimit,
ServicePeerBaseLimit: infiniteBaseLimit,
ServicePeerMemory: infiniteMemoryLimit,
ProtocolBaseLimit: infiniteBaseLimit,
ProtocolMemory: infiniteMemoryLimit,
ProtocolPeerBaseLimit: infiniteBaseLimit,
ProtocolPeerMemory: infiniteMemoryLimit,
PeerBaseLimit: infiniteBaseLimit,
PeerMemory: infiniteMemoryLimit,
ConnBaseLimit: infiniteBaseLimit,
ConnMemory: math.MaxInt64,
StreamBaseLimit: infiniteBaseLimit,
StreamMemory: math.MaxInt64,
}

0 comments on commit 6e563a8

Please sign in to comment.