Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 00dc67c

Browse files
committedNov 28, 2015
low memory setting for bitswap
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent a6a1dbc commit 00dc67c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎exchange/bitswap/bitswap.go

+11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
2323
peer "github.com/ipfs/go-ipfs/p2p/peer"
2424
"github.com/ipfs/go-ipfs/thirdparty/delay"
25+
u "github.com/ipfs/go-ipfs/util"
2526
logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log"
2627
)
2728

@@ -39,12 +40,22 @@ const (
3940
sizeBatchRequestChan = 32
4041
// kMaxPriority is the max priority as defined by the bitswap protocol
4142
kMaxPriority = math.MaxInt32
43+
)
4244

45+
var (
4346
HasBlockBufferSize = 256
4447
provideKeysBufferSize = 2048
4548
provideWorkerMax = 512
4649
)
4750

51+
func init() {
52+
if u.LowMemMode {
53+
HasBlockBufferSize = 64
54+
provideKeysBufferSize = 512
55+
provideWorkerMax = 16
56+
}
57+
}
58+
4859
var rebroadcastDelay = delay.Fixed(time.Second * 10)
4960

5061
// New initializes a BitSwap instance that communicates over the provided

0 commit comments

Comments
 (0)
Please sign in to comment.