From 20847845e2d7518515ba514815b1987de8f95e27 Mon Sep 17 00:00:00 2001 From: Sanket Shanbhag Date: Sun, 1 Jan 2023 17:19:00 +0530 Subject: [PATCH] feat: raise fd limit of the binary (#668) * raise fd limit of the binary * Remove tracing and return error * Ignore errors --- Cargo.lock | 10 ++++++++++ bin/reth/Cargo.toml | 1 + bin/reth/src/node/mod.rs | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index edd37ef37..3a45012cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1437,6 +1437,15 @@ dependencies = [ "instant", ] +[[package]] +name = "fdlimit" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4c9e43643f5a3be4ca5b67d26b98031ff9db6806c3440ae32e02e3ceac3f1b" +dependencies = [ + "libc", +] + [[package]] name = "ff" version = "0.12.1" @@ -3415,6 +3424,7 @@ dependencies = [ "confy", "dirs-next", "eyre", + "fdlimit", "futures", "metrics", "metrics-exporter-prometheus", diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 181aaddcb..622d88fc6 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -28,6 +28,7 @@ tracing-futures = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } # io +fdlimit = "0.2.1" walkdir = "2.3" serde = "1.0" serde_json = "1.0" diff --git a/bin/reth/src/node/mod.rs b/bin/reth/src/node/mod.rs index db7ebf52c..fe774946b 100644 --- a/bin/reth/src/node/mod.rs +++ b/bin/reth/src/node/mod.rs @@ -8,6 +8,7 @@ use crate::{ util::chainspec::{chain_spec_value_parser, ChainSpecification, Genesis}, }; use clap::{crate_version, Parser}; +use fdlimit::raise_fd_limit; use reth_consensus::BeaconConsensus; use reth_db::{ cursor::DbCursorRO, @@ -85,6 +86,10 @@ impl Command { /// Execute `node` command // TODO: RPC pub async fn execute(&self) -> eyre::Result<()> { + // Raise the fd limit of the process. + // Does not do anything on windows. + raise_fd_limit(); + let config: Config = confy::load_path(&self.config).unwrap_or_default(); info!("reth {} starting", crate_version!());