Add --rpc-threads argument

This commit is contained in:
Michael Vines 2021-01-12 17:13:47 -08:00
parent e1b59ded4b
commit 11daaadc93
6 changed files with 17 additions and 2 deletions

1
Cargo.lock generated
View File

@ -5115,6 +5115,7 @@ dependencies = [
"indicatif",
"libc",
"log 0.4.11",
"num_cpus",
"rand 0.7.3",
"serde_json",
"signal-hook",

View File

@ -38,7 +38,6 @@ log = "0.4.11"
lru = "0.6.1"
miow = "0.2.2"
net2 = "0.2.37"
num_cpus = "1.13.0"
num-traits = "0.2"
rand = "0.7.0"
rand_chacha = "0.2.2"
@ -88,6 +87,7 @@ trees = "0.2.1"
[dev-dependencies]
matches = "0.1.6"
num_cpus = "1.13.0"
reqwest = { version = "0.10.8", default-features = false, features = ["blocking", "rustls-tls", "json"] }
serial_test = "0.4.0"
serial_test_derive = "0.4.0"

View File

@ -112,6 +112,7 @@ pub struct JsonRpcConfig {
pub enable_bigtable_ledger_upload: bool,
pub max_multiple_accounts: Option<usize>,
pub account_indexes: HashSet<AccountIndex>,
pub rpc_threads: usize,
}
#[derive(Clone)]

View File

@ -273,6 +273,7 @@ impl JsonRpcService {
) -> Self {
info!("rpc bound to {:?}", rpc_addr);
info!("rpc configuration: {:?}", config);
let rpc_threads = 1.max(config.rpc_threads);
let health = Arc::new(RpcHealth::new(
cluster_info.clone(),
@ -374,7 +375,7 @@ impl JsonRpcService {
io,
move |_req: &hyper::Request<hyper::Body>| request_processor.clone(),
)
.threads(num_cpus::get())
.threads(rpc_threads)
.cors(DomainsValidation::AllowOnly(vec![
AccessControlAllowOrigin::Any,
]))

View File

@ -19,6 +19,7 @@ core_affinity = "0.5.10"
fd-lock = "1.1.1"
indicatif = "0.15.0"
log = "0.4.11"
num_cpus = "1.13.0"
rand = "0.7.0"
serde_json = "1.0.56"
solana-clap-utils = { path = "../clap-utils", version = "1.6.0" }

View File

@ -826,6 +826,7 @@ pub fn main() {
let default_rpc_send_transaction_leader_forward_count = ValidatorConfig::default()
.send_transaction_leader_forward_count
.to_string();
let default_rpc_threads = num_cpus::get().to_string();
let matches = App::new(crate_name!()).about(crate_description!())
.version(solana_version::version!())
@ -1277,6 +1278,15 @@ pub fn main() {
.validator(solana_net_utils::is_host)
.help("IP address to bind the RPC port [default: use --bind-address]"),
)
.arg(
Arg::with_name("rpc_threads")
.long("rpc-threads")
.value_name("NUMBER")
.validator(is_parsable::<usize>)
.takes_value(true)
.default_value(&default_rpc_threads)
.help("Number of threads to use for servicing RPC requests"),
)
.arg(
Arg::with_name("rpc_pubsub_enable_vote_subscription")
.long("rpc-pubsub-enable-vote-subscription")
@ -1550,6 +1560,7 @@ pub fn main() {
"health_check_slot_distance",
u64
),
rpc_threads: value_t_or_exit!(matches, "rpc_threads", usize),
account_indexes: account_indexes.clone(),
},
rpc_addrs: value_t!(matches, "rpc_port", u16).ok().map(|rpc_port| {