Fix: RM: Improve init RM message and fix final memory value.
Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
Antonio Navarro Perez committed
Dec 7, 2022 at 11:17 UTC
67886f7bd3936301ce21d554f20b1ec4273ecd1f
1 file changed
+15
-2
core/node/libp2p/rcmgr_defaults.go
+15
-2
@@ -1,6 +1,8 @@
1
package libp2p
2
3
import (
4
+ "fmt"
5
+
6
"github.com/dustin/go-humanize"
7
"github.com/libp2p/go-libp2p"
8
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
@@ -54,10 +56,21 @@ func createDefaultLimitConfig(cfg config.SwarmConfig) (rcmgr.LimitConfig, error)
56
57
numFD := cfg.ResourceMgr.MaxFileDescriptors.WithDefault(int64(fd.GetNumFDs()) / 2)
58
59
+ // We want to see this message on startup, that's why we are using fmt instead of log.
60
+ fmt.Printf(`
61
+Computing default go-libp2p Resource Manager limits based on:
62
+ - 'Swarm.ResourceMgr.MaxMemory': %q
63
+ - 'Swarm.ResourceMgr.MaxFileDescriptors': %d
64
+
65
+Applying any user-supplied overrides on top.
66
+Run 'ipfs swarm limit all' to see the resulting limits.
67
+
68
+`, maxMemoryString, numFD)
69
+
70
scalingLimitConfig := rcmgr.ScalingLimitConfig{
71
SystemBaseLimit: rcmgr.BaseLimit{
59
- Memory: int64(maxMemory),
60
- FD: int(numFD),
72
+ Memory: rcmgr.DefaultLimits.SystemBaseLimit.Memory,
73
+ FD: rcmgr.DefaultLimits.SystemBaseLimit.FD,
74
75
// By default, we just limit connections on the inbound side.
76
Conns: bigEnough,