2022-05-20 08:12:52 +00:00
|
|
|
package fdlimits
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/common/fdlimit"
|
2022-07-01 22:05:01 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2022-05-20 08:12:52 +00:00
|
|
|
)
|
|
|
|
|
2022-07-01 22:05:01 +00:00
|
|
|
var log = logrus.WithField("prefix", "fdlimits")
|
|
|
|
|
2022-05-20 08:12:52 +00:00
|
|
|
// 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
|
|
|
|
}
|
2022-07-01 22:05:01 +00:00
|
|
|
log.Debugf("Updated file descriptor limit to %d from %d", raisedVal, curr)
|
2022-05-20 08:12:52 +00:00
|
|
|
return nil
|
|
|
|
}
|