Add validator option to change niceness of RPC server threads
Fixes https://github.com/solana-labs/solana/issues/14556
This commit is contained in:
parent
c78f474373
commit
0e751ef7df
|
@ -143,6 +143,7 @@ pub struct JsonRpcConfig {
|
|||
pub max_multiple_accounts: Option<usize>,
|
||||
pub account_indexes: AccountSecondaryIndexes,
|
||||
pub rpc_threads: usize,
|
||||
pub rpc_niceness_adj: i8,
|
||||
pub rpc_bigtable_timeout: Option<Duration>,
|
||||
pub minimal_api: bool,
|
||||
pub obsolete_v1_7_api: bool,
|
||||
|
|
|
@ -24,6 +24,7 @@ use {
|
|||
leader_schedule_cache::LeaderScheduleCache,
|
||||
},
|
||||
solana_metrics::inc_new_counter_info,
|
||||
solana_perf::thread::renice_this_thread,
|
||||
solana_poh::poh_recorder::PohRecorder,
|
||||
solana_runtime::{
|
||||
bank_forks::BankForks, commitment::BlockCommitmentCache,
|
||||
|
@ -305,6 +306,7 @@ impl JsonRpcService {
|
|||
info!("rpc bound to {:?}", rpc_addr);
|
||||
info!("rpc configuration: {:?}", config);
|
||||
let rpc_threads = 1.max(config.rpc_threads);
|
||||
let rpc_niceness_adj = config.rpc_niceness_adj;
|
||||
|
||||
let health = Arc::new(RpcHealth::new(
|
||||
cluster_info.clone(),
|
||||
|
@ -328,6 +330,7 @@ impl JsonRpcService {
|
|||
let runtime = Arc::new(
|
||||
tokio::runtime::Builder::new_multi_thread()
|
||||
.worker_threads(rpc_threads)
|
||||
.on_thread_start(move || renice_this_thread(rpc_niceness_adj).unwrap())
|
||||
.thread_name("sol-rpc-el")
|
||||
.enable_all()
|
||||
.build()
|
||||
|
@ -411,6 +414,8 @@ impl JsonRpcService {
|
|||
let thread_hdl = Builder::new()
|
||||
.name("solana-jsonrpc".to_string())
|
||||
.spawn(move || {
|
||||
renice_this_thread(rpc_niceness_adj).unwrap();
|
||||
|
||||
let mut io = MetaIoHandler::default();
|
||||
|
||||
io.extend_with(rpc_minimal::MinimalImpl.to_delegate());
|
||||
|
|
|
@ -1173,6 +1173,16 @@ pub fn main() {
|
|||
.default_value(&default_rpc_threads)
|
||||
.help("Number of threads to use for servicing RPC requests"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("rpc_niceness_adj")
|
||||
.long("rpc-niceness-adjustment")
|
||||
.value_name("ADJUSTMENT")
|
||||
.takes_value(true)
|
||||
.validator(is_niceness_adjustment_valid)
|
||||
.default_value("0")
|
||||
.help("Add this value to niceness of RPC threads. Negative value \
|
||||
increases priority, positive value decreases priority.")
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("rpc_bigtable_timeout")
|
||||
.long("rpc-bigtable-timeout")
|
||||
|
@ -2180,6 +2190,7 @@ pub fn main() {
|
|||
u64
|
||||
),
|
||||
rpc_threads: value_t_or_exit!(matches, "rpc_threads", usize),
|
||||
rpc_niceness_adj: value_t_or_exit!(matches, "rpc_niceness_adj", i8),
|
||||
rpc_bigtable_timeout: value_t!(matches, "rpc_bigtable_timeout", u64)
|
||||
.ok()
|
||||
.map(Duration::from_secs),
|
||||
|
|
Loading…
Reference in New Issue