1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 13:22:21 +08:00

introduce low memory flag

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2015-11-27 16:03:16 -08:00
parent cdddf0ff51
commit 7d0c46affc
2 changed files with 24 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import (
bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network"
notifications "github.com/ipfs/go-ipfs/exchange/bitswap/notifications"
wantlist "github.com/ipfs/go-ipfs/exchange/bitswap/wantlist"
flags "github.com/ipfs/go-ipfs/flags"
"github.com/ipfs/go-ipfs/thirdparty/delay"
process "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
procctx "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess/context"
@ -39,12 +40,22 @@ const (
sizeBatchRequestChan = 32
// kMaxPriority is the max priority as defined by the bitswap protocol
kMaxPriority = math.MaxInt32
)
var (
HasBlockBufferSize = 256
provideKeysBufferSize = 2048
provideWorkerMax = 512
)
func init() {
if flags.LowMemMode {
HasBlockBufferSize = 64
provideKeysBufferSize = 512
provideWorkerMax = 16
}
}
var rebroadcastDelay = delay.Fixed(time.Second * 10)
// New initializes a BitSwap instance that communicates over the provided

13
flags/flags.go Normal file
View File

@ -0,0 +1,13 @@
package flags
import (
"os"
)
var LowMemMode bool
func init() {
if os.Getenv("IPFS_LOW_MEM") != "" {
LowMemMode = true
}
}