From 89b666f703b66b3da0a5add04913eaa9b3fd4c55 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 6 Jun 2022 11:56:08 +0200 Subject: [PATCH] add a DefaultLimitConfig with infinite limits (#41) This is useful when recording a trace to observe the baseline resource consumption. --- limit_defaults.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/limit_defaults.go b/limit_defaults.go index 8d5e3cd..72e51a8 100644 --- a/limit_defaults.go +++ b/limit_defaults.go @@ -1,5 +1,7 @@ package rcmgr +import "math" + // DefaultLimitConfig is a struct for configuring default limits. type DefaultLimitConfig struct { SystemBaseLimit BaseLimit @@ -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, +}