Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise fdlimit #200

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- feat: raise file-descriptor limit
- fix: docker
- fix: pending storage & sequencer_provider
- refactor: support pending blocks & db crate
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ rayon = "1.10"
crossbeam-skiplist = "0.1"
bincode = "1.3"
prometheus = "0.13.4"
fdlimit = "0.3.0"

[patch.crates-io]
starknet-core = { git = "https://github.com/kasarlabs/starknet-rs.git", branch = "fork" }
Expand Down
1 change: 1 addition & 0 deletions crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ anyhow.workspace = true
chrono = "0.4.38"
clap = { workspace = true, features = ["derive"] }
env_logger = "0.11.3"
fdlimit.workspace = true
forwarded-header-value = "0.1.1"
futures = { workspace = true, features = ["thread-pool"] }
governor.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const GREET_AUTHORS: &[&str] = &["KasarLabs <https://kasar.io>"];

#[tokio::main]
async fn main() -> anyhow::Result<()> {
crate::util::setup_rayon_threadpool()?;
crate::util::setup_logging()?;
crate::util::setup_rayon_threadpool()?;
crate::util::raise_fdlimit();

let mut run_cmd: RunCmd = RunCmd::parse();
let node_name = run_cmd.node_name_or_provide().await.to_string();
Expand Down
23 changes: 23 additions & 0 deletions crates/node/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ pub fn setup_rayon_threadpool() -> anyhow::Result<()> {
Ok(())
}

pub fn raise_fdlimit() {
use fdlimit::Outcome;
let recommended = 10000;
match fdlimit::raise_fd_limit() {
Ok(Outcome::LimitRaised { to, .. }) if to < recommended => {
log::warn!(
"The file-descriptor limit for the current process is {to}, which is lower than the recommended {recommended}."
);
}
Ok(Outcome::LimitRaised { to, .. }) => {
log::debug!("File-descriptor limit was raised to {to}.");
}
Err(error) => {
log::warn!(
"Error while trying to raise the file-descriptor limit for the process: {error:#}. The recommended file-descriptor limit is {recommended}."
);
}
Ok(Outcome::Unsupported) => {
log::debug!("Unsupported platform for raising file-descriptor limit.");
}
}
}

// Todo: Setup tracing
pub fn setup_logging() -> anyhow::Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
Expand Down
Loading