Skip to content

Commit

Permalink
demo: try to set max open files
Browse files Browse the repository at this point in the history
  • Loading branch information
BohuTANG committed Oct 23, 2022
1 parent 1983e4f commit c6fb934
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions src/binaries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ openraft = { workspace = true }
sentry = "0.27.0"
serde = { workspace = true }
serde_json = { workspace = true }
sysinfo = "0.26.5"
tokio-stream = "0.1.10"
tonic = "0.8.1"
tracing = "0.1.36"
url = "2.3.1"
limits_rs = "0.1.0"
sysinfo = "0.26.5"

[[bin]]
name = "databend-meta"
Expand Down
27 changes: 15 additions & 12 deletions src/binaries/query/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ use databend_query::servers::MySQLHandler;
use databend_query::servers::Server;
use databend_query::servers::ShutdownHandle;
use databend_query::GlobalServices;
use limits_rs::get_own_limits;
use sysinfo::set_open_files_limit;
use tracing::info;
use tracing::warn;

Expand Down Expand Up @@ -76,16 +74,8 @@ async fn main(_global_tracker: Arc<RuntimeTracker>) -> common_exception::Result<
init_default_metrics_recorder();
set_panic_hook();

let limits = get_own_limits().unwrap();
let max_open_files_soft_limit = limits.max_open_files.soft;
match max_open_files_soft_limit {
Some(limit) => {
if limit < 65535 && set_open_files_limit(65535) {
warn!("Open files limit has been set to {}", 65535);
}
}
None => {}
}
// Try to set max open files.
try_set_max_open_files();

GlobalServices::init(conf.clone()).await?;
let mut shutdown_handle = ShutdownHandle::create()?;
Expand Down Expand Up @@ -265,3 +255,16 @@ fn run_cmd(conf: &Config) -> bool {

true
}

fn try_set_max_open_files() {
let max_open_files = 65535;
let set = sysinfo::set_open_files_limit(max_open_files);

This comment has been minimized.

Copy link
@BohuTANG

BohuTANG Oct 23, 2022

Author Owner

limit-rs check still need, this is a try_set_max_open_files example.

match set {
true => {
warn!("Open files limit has been set to {}", max_open_files);
}
false => {
warn!("Open files limit set to {} failed", max_open_files);
}
}
}

0 comments on commit c6fb934

Please sign in to comment.