Adjust nofiles within Blocktree::open() for all ledger/ users (#6737)
automerge
This commit is contained in:
parent
b9d8e3e55a
commit
7203036e3e
|
@ -3281,7 +3281,6 @@ dependencies = [
|
||||||
"jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -3542,6 +3541,7 @@ dependencies = [
|
||||||
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -408,45 +408,6 @@ impl Validator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
|
||||||
fn adjust_ulimit_nofile() {}
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
fn adjust_ulimit_nofile() {
|
|
||||||
// Rocks DB likes to have many open files. The default open file descriptor limit is
|
|
||||||
// usually not enough
|
|
||||||
let desired_nofile = 65000;
|
|
||||||
|
|
||||||
fn get_nofile() -> libc::rlimit {
|
|
||||||
let mut nofile = libc::rlimit {
|
|
||||||
rlim_cur: 0,
|
|
||||||
rlim_max: 0,
|
|
||||||
};
|
|
||||||
if unsafe { libc::getrlimit(libc::RLIMIT_NOFILE, &mut nofile) } != 0 {
|
|
||||||
warn!("getrlimit(RLIMIT_NOFILE) failed");
|
|
||||||
}
|
|
||||||
nofile
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut nofile = get_nofile();
|
|
||||||
if nofile.rlim_cur < desired_nofile {
|
|
||||||
nofile.rlim_cur = desired_nofile;
|
|
||||||
if unsafe { libc::setrlimit(libc::RLIMIT_NOFILE, &nofile) } != 0 {
|
|
||||||
error!(
|
|
||||||
"Unable to increase the maximum open file descriptor limit to {}",
|
|
||||||
desired_nofile
|
|
||||||
);
|
|
||||||
|
|
||||||
if cfg!(target_os = "macos") {
|
|
||||||
error!("On mac OS you may need to run |sudo launchctl limit maxfiles 65536 200000| first");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nofile = get_nofile();
|
|
||||||
}
|
|
||||||
info!("Maximum open file descriptors: {}", nofile.rlim_cur);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_banks_from_blocktree(
|
pub fn new_banks_from_blocktree(
|
||||||
expected_genesis_blockhash: Option<Hash>,
|
expected_genesis_blockhash: Option<Hash>,
|
||||||
blocktree_path: &Path,
|
blocktree_path: &Path,
|
||||||
|
@ -482,8 +443,6 @@ pub fn new_banks_from_blocktree(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
adjust_ulimit_nofile();
|
|
||||||
|
|
||||||
let (blocktree, ledger_signal_receiver, completed_slots_receiver) =
|
let (blocktree, ledger_signal_receiver, completed_slots_receiver) =
|
||||||
Blocktree::open_with_signal(blocktree_path).expect("Failed to open ledger database");
|
Blocktree::open_with_signal(blocktree_path).expect("Failed to open ledger database");
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ dlopen_derive = "0.1.4"
|
||||||
fs_extra = "1.1.0"
|
fs_extra = "1.1.0"
|
||||||
itertools = "0.8.1"
|
itertools = "0.8.1"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
libc = "0.2.65"
|
||||||
log = { version = "0.4.8" }
|
log = { version = "0.4.8" }
|
||||||
rand = "0.6.5"
|
rand = "0.6.5"
|
||||||
rand_chacha = "0.1.1"
|
rand_chacha = "0.1.1"
|
||||||
|
|
|
@ -135,6 +135,8 @@ impl Blocktree {
|
||||||
fs::create_dir_all(&ledger_path)?;
|
fs::create_dir_all(&ledger_path)?;
|
||||||
let blocktree_path = ledger_path.join(BLOCKTREE_DIRECTORY);
|
let blocktree_path = ledger_path.join(BLOCKTREE_DIRECTORY);
|
||||||
|
|
||||||
|
adjust_ulimit_nofile();
|
||||||
|
|
||||||
// Open the database
|
// Open the database
|
||||||
let db = Database::open(&blocktree_path)?;
|
let db = Database::open(&blocktree_path)?;
|
||||||
|
|
||||||
|
@ -1834,6 +1836,45 @@ pub fn make_chaining_slot_entries(
|
||||||
slots_shreds_and_entries
|
slots_shreds_and_entries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
fn adjust_ulimit_nofile() {}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn adjust_ulimit_nofile() {
|
||||||
|
// Rocks DB likes to have many open files. The default open file descriptor limit is
|
||||||
|
// usually not enough
|
||||||
|
let desired_nofile = 65000;
|
||||||
|
|
||||||
|
fn get_nofile() -> libc::rlimit {
|
||||||
|
let mut nofile = libc::rlimit {
|
||||||
|
rlim_cur: 0,
|
||||||
|
rlim_max: 0,
|
||||||
|
};
|
||||||
|
if unsafe { libc::getrlimit(libc::RLIMIT_NOFILE, &mut nofile) } != 0 {
|
||||||
|
warn!("getrlimit(RLIMIT_NOFILE) failed");
|
||||||
|
}
|
||||||
|
nofile
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut nofile = get_nofile();
|
||||||
|
if nofile.rlim_cur < desired_nofile {
|
||||||
|
nofile.rlim_cur = desired_nofile;
|
||||||
|
if unsafe { libc::setrlimit(libc::RLIMIT_NOFILE, &nofile) } != 0 {
|
||||||
|
error!(
|
||||||
|
"Unable to increase the maximum open file descriptor limit to {}",
|
||||||
|
desired_nofile
|
||||||
|
);
|
||||||
|
|
||||||
|
if cfg!(target_os = "macos") {
|
||||||
|
error!("On mac OS you may need to run |sudo launchctl limit maxfiles 65536 200000| first");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nofile = get_nofile();
|
||||||
|
}
|
||||||
|
info!("Maximum open file descriptors: {}", nofile.rlim_cur);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod tests {
|
pub mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in New Issue