-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
588dea8
commit f28b47b
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.") | ||
|
||
} |