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 max_multiple_accounts: Option<usize>,
|
||||||
pub account_indexes: AccountSecondaryIndexes,
|
pub account_indexes: AccountSecondaryIndexes,
|
||||||
pub rpc_threads: usize,
|
pub rpc_threads: usize,
|
||||||
|
pub rpc_niceness_adj: i8,
|
||||||
pub rpc_bigtable_timeout: Option<Duration>,
|
pub rpc_bigtable_timeout: Option<Duration>,
|
||||||
pub minimal_api: bool,
|
pub minimal_api: bool,
|
||||||
pub obsolete_v1_7_api: bool,
|
pub obsolete_v1_7_api: bool,
|
||||||
|
|
|
@ -24,6 +24,7 @@ use {
|
||||||
leader_schedule_cache::LeaderScheduleCache,
|
leader_schedule_cache::LeaderScheduleCache,
|
||||||
},
|
},
|
||||||
solana_metrics::inc_new_counter_info,
|
solana_metrics::inc_new_counter_info,
|
||||||
|
solana_perf::thread::renice_this_thread,
|
||||||
solana_poh::poh_recorder::PohRecorder,
|
solana_poh::poh_recorder::PohRecorder,
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
bank_forks::BankForks, commitment::BlockCommitmentCache,
|
bank_forks::BankForks, commitment::BlockCommitmentCache,
|
||||||
|
@ -305,6 +306,7 @@ impl JsonRpcService {
|
||||||
info!("rpc bound to {:?}", rpc_addr);
|
info!("rpc bound to {:?}", rpc_addr);
|
||||||
info!("rpc configuration: {:?}", config);
|
info!("rpc configuration: {:?}", config);
|
||||||
let rpc_threads = 1.max(config.rpc_threads);
|
let rpc_threads = 1.max(config.rpc_threads);
|
||||||
|
let rpc_niceness_adj = config.rpc_niceness_adj;
|
||||||
|
|
||||||
let health = Arc::new(RpcHealth::new(
|
let health = Arc::new(RpcHealth::new(
|
||||||
cluster_info.clone(),
|
cluster_info.clone(),
|
||||||
|
@ -328,6 +330,7 @@ impl JsonRpcService {
|
||||||
let runtime = Arc::new(
|
let runtime = Arc::new(
|
||||||
tokio::runtime::Builder::new_multi_thread()
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
.worker_threads(rpc_threads)
|
.worker_threads(rpc_threads)
|
||||||
|
.on_thread_start(move || renice_this_thread(rpc_niceness_adj).unwrap())
|
||||||
.thread_name("sol-rpc-el")
|
.thread_name("sol-rpc-el")
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()
|
.build()
|
||||||
|
@ -411,6 +414,8 @@ impl JsonRpcService {
|
||||||
let thread_hdl = Builder::new()
|
let thread_hdl = Builder::new()
|
||||||
.name("solana-jsonrpc".to_string())
|
.name("solana-jsonrpc".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
renice_this_thread(rpc_niceness_adj).unwrap();
|
||||||
|
|
||||||
let mut io = MetaIoHandler::default();
|
let mut io = MetaIoHandler::default();
|
||||||
|
|
||||||
io.extend_with(rpc_minimal::MinimalImpl.to_delegate());
|
io.extend_with(rpc_minimal::MinimalImpl.to_delegate());
|
||||||
|
|
|
@ -1173,6 +1173,16 @@ pub fn main() {
|
||||||
.default_value(&default_rpc_threads)
|
.default_value(&default_rpc_threads)
|
||||||
.help("Number of threads to use for servicing RPC requests"),
|
.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(
|
||||||
Arg::with_name("rpc_bigtable_timeout")
|
Arg::with_name("rpc_bigtable_timeout")
|
||||||
.long("rpc-bigtable-timeout")
|
.long("rpc-bigtable-timeout")
|
||||||
|
@ -2180,6 +2190,7 @@ pub fn main() {
|
||||||
u64
|
u64
|
||||||
),
|
),
|
||||||
rpc_threads: value_t_or_exit!(matches, "rpc_threads", usize),
|
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)
|
rpc_bigtable_timeout: value_t!(matches, "rpc_bigtable_timeout", u64)
|
||||||
.ok()
|
.ok()
|
||||||
.map(Duration::from_secs),
|
.map(Duration::from_secs),
|
||||||
|
|
Loading…
Reference in New Issue