mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 15:42:21 +08:00
Merge pull request #2429 from ipfs/feat/low-mem-experiment
introduce a low memory flag
This commit is contained in:
@ -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
13
flags/flags.go
Normal file
@ -0,0 +1,13 @@
|
||||
package flags
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
var LowMemMode bool
|
||||
|
||||
func init() {
|
||||
if os.Getenv("IPFS_LOW_MEM") != "" {
|
||||
LowMemMode = true
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user