mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 00:27:38 +00:00
Raise Soft File Descriptor Limit Up To The Hard Limit (#10650)
* add changes * comment * kasey's review Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
588dea83b7
commit
f28b47bd87
@ -28,6 +28,7 @@ go_library(
|
|||||||
"//io/logs:go_default_library",
|
"//io/logs:go_default_library",
|
||||||
"//monitoring/journald:go_default_library",
|
"//monitoring/journald:go_default_library",
|
||||||
"//runtime/debug:go_default_library",
|
"//runtime/debug:go_default_library",
|
||||||
|
"//runtime/fdlimits:go_default_library",
|
||||||
"//runtime/maxprocs:go_default_library",
|
"//runtime/maxprocs:go_default_library",
|
||||||
"//runtime/tos:go_default_library",
|
"//runtime/tos:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/io/logs"
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/debug"
|
"github.com/prysmaticlabs/prysm/runtime/debug"
|
||||||
|
"github.com/prysmaticlabs/prysm/runtime/fdlimits"
|
||||||
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/tos"
|
"github.com/prysmaticlabs/prysm/runtime/tos"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||||
@ -193,6 +194,9 @@ func main() {
|
|||||||
if err := debug.Setup(ctx); err != nil {
|
if err := debug.Setup(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := fdlimits.SetMaxFdLimits(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return cmd.ValidateNoArgs(ctx)
|
return cmd.ValidateNoArgs(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
runtime/fdlimits/BUILD.bazel
Normal file
22
runtime/fdlimits/BUILD.bazel
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "go_default_library",
|
||||||
|
srcs = ["fdlimits.go"],
|
||||||
|
importpath = "github.com/prysmaticlabs/prysm/runtime/fdlimits",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = [
|
||||||
|
"@com_github_ethereum_go_ethereum//common/fdlimit:go_default_library",
|
||||||
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
go_test(
|
||||||
|
name = "go_default_test",
|
||||||
|
srcs = ["fdlimits_test.go"],
|
||||||
|
deps = [
|
||||||
|
":go_default_library",
|
||||||
|
"//testing/assert:go_default_library",
|
||||||
|
"@com_github_ethereum_go_ethereum//common/fdlimit:go_default_library",
|
||||||
|
],
|
||||||
|
)
|
25
runtime/fdlimits/fdlimits.go
Normal file
25
runtime/fdlimits/fdlimits.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package fdlimits
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetMaxFdLimits is a wrapper around a few go-ethereum methods to allow prysm to
|
||||||
|
// set its file descriptor limits at the maximum possible value.
|
||||||
|
func SetMaxFdLimits() error {
|
||||||
|
curr, err := fdlimit.Current()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
max, err := fdlimit.Maximum()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
raisedVal, err := fdlimit.Raise(uint64(max))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Infof("Raised fd limit to %d from %d", raisedVal, curr)
|
||||||
|
return nil
|
||||||
|
}
|
22
runtime/fdlimits/fdlimits_test.go
Normal file
22
runtime/fdlimits/fdlimits_test.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package fdlimits_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
gethLimit "github.com/ethereum/go-ethereum/common/fdlimit"
|
||||||
|
"github.com/prysmaticlabs/prysm/runtime/fdlimits"
|
||||||
|
"github.com/prysmaticlabs/prysm/testing/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSetMaxFdLimits(t *testing.T) {
|
||||||
|
assert.NoError(t, fdlimits.SetMaxFdLimits())
|
||||||
|
|
||||||
|
curr, err := gethLimit.Current()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
max, err := gethLimit.Maximum()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Equal(t, max, curr, "current and maximum file descriptor limits do not match up.")
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user