Add validator option to change niceness of RPC server threads

Fixes https://github.com/solana-labs/solana/issues/14556
This commit is contained in:
Ivan Mironov
2021-10-27 08:13:19 +05:00
committed by Trent Nelson
parent c78f474373
commit 0e751ef7df
3 changed files with 17 additions and 0 deletions

View File

@ -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,

View File

@ -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());