Skip to content

Commit

Permalink
alerting: Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Aug 26, 2021
1 parent 667836f commit 5ef86d4
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 8 deletions.
6 changes: 6 additions & 0 deletions build/limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package build

var (
DefaultFDLimit uint64 = 16 << 10
MinerFDLimit uint64 = 100_000
)
Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
10 changes: 6 additions & 4 deletions lib/ulimit/ulimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package ulimit

import (
"fmt"
"github.com/filecoin-project/lotus/build"
"os"
"strconv"
"syscall"
Expand All @@ -17,16 +18,17 @@ var (
supportsFDManagement = false

// getlimit returns the soft and hard limits of file descriptors counts
GetLimit func() (uint64, uint64, error)
getLimit func() (uint64, uint64, error)
// set limit sets the soft and hard limits of file descriptors counts
setLimit func(uint64, uint64) error
)

// minimum file descriptor limit before we complain
const minFds = 2048

// default max file descriptor limit.
const maxFds = 16 << 10
func GetLimit() (uint64, uint64, error) {
return getLimit()
}

// userMaxFDs returns the value of LOTUS_FD_MAX
func userMaxFDs() uint64 {
Expand Down Expand Up @@ -55,7 +57,7 @@ func ManageFdLimit() (changed bool, newLimit uint64, err error) {
return false, 0, nil
}

targetLimit := uint64(maxFds)
targetLimit := build.DefaultFDLimit
userLimit := userMaxFDs()
if userLimit > 0 {
targetLimit = userLimit
Expand Down
2 changes: 1 addition & 1 deletion lib/ulimit/ulimit_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func init() {
supportsFDManagement = true
GetLimit = freebsdGetLimit
getLimit = freebsdGetLimit
setLimit = freebsdSetLimit
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ulimit/ulimit_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func init() {
supportsFDManagement = true
GetLimit = unixGetLimit
getLimit = unixGetLimit
setLimit = unixSetLimit
}

Expand Down
3 changes: 2 additions & 1 deletion node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"go.uber.org/fx"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
Expand Down Expand Up @@ -152,7 +153,7 @@ func defaults() []Option {
Override(new(journal.Journal), modules.OpenFilesystemJournal),
Override(new(*alerting.Alerting), alerting.NewAlertingSystem),

Override(CheckFDLimit, modules.CheckFdLimit(16<<10)),
Override(CheckFDLimit, modules.CheckFdLimit(build.DefaultFDLimit)),

Override(new(system.MemoryConstraints), modules.MemoryConstraints),
Override(InitMemoryWatchdog, modules.MemoryWatchdog),
Expand Down
3 changes: 2 additions & 1 deletion node/builder_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
storage2 "github.com/filecoin-project/specs-storage/storage"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
Expand Down Expand Up @@ -74,7 +75,7 @@ func ConfigStorageMiner(c interface{}) Option {
return Options(
ConfigCommon(&cfg.Common, enableLibp2pNode),

Override(CheckFDLimit, modules.CheckFdLimit(100_000)), // recommend at least 100k FD limit to miners
Override(CheckFDLimit, modules.CheckFdLimit(build.MinerFDLimit)), // recommend at least 100k FD limit to miners

Override(new(api.MinerSubsystems), modules.ExtractEnabledMinerSubsystems(cfg.Subsystems)),
Override(new(stores.LocalStorage), From(new(repo.LockedRepo))),
Expand Down

0 comments on commit 5ef86d4

Please sign in to comment.