From c809589b5fc473e0daaa80d20788851b8ceb8269 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 28 Nov 2015 15:49:03 -0800 Subject: [PATCH] low mem experiemnt on dials License: MIT Signed-off-by: Jeromy --- p2p/net/swarm/swarm_dial.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/p2p/net/swarm/swarm_dial.go b/p2p/net/swarm/swarm_dial.go index 6d4e0344e18..17e7bf1019f 100644 --- a/p2p/net/swarm/swarm_dial.go +++ b/p2p/net/swarm/swarm_dial.go @@ -12,6 +12,7 @@ import ( conn "github.com/ipfs/go-ipfs/p2p/net/conn" addrutil "github.com/ipfs/go-ipfs/p2p/net/swarm/addr" peer "github.com/ipfs/go-ipfs/p2p/peer" + u "github.com/ipfs/go-ipfs/util" lgbl "github.com/ipfs/go-ipfs/util/eventlog/loggables" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" @@ -41,7 +42,14 @@ var ( const dialAttempts = 1 // number of concurrent outbound dials over transports that consume file descriptors -const concurrentFdDials = 160 +var concurrentFdDials = 160 + +func init() { + if u.LowMemMode { + concurrentFdDials = 80 + DialTimeout = time.Second * 8 + } +} // DialTimeout is the amount of time each dial attempt has. We can think about making // this larger down the road, or putting more granular timeouts (i.e. within each