Add validator option to change niceness of snapshot packager thread
This commit is contained in:
committed by
Trent Nelson
parent
18b1baa3c1
commit
c78f474373
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4558,6 +4558,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"clap 2.33.3",
|
"clap 2.33.3",
|
||||||
"rpassword",
|
"rpassword",
|
||||||
|
"solana-perf",
|
||||||
"solana-remote-wallet",
|
"solana-remote-wallet",
|
||||||
"solana-sdk",
|
"solana-sdk",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
@ -12,6 +12,7 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.0"
|
clap = "2.33.0"
|
||||||
rpassword = "5.0"
|
rpassword = "5.0"
|
||||||
|
solana-perf = { path = "../perf", version = "=1.9.0" }
|
||||||
solana-remote-wallet = { path = "../remote-wallet", version = "=1.9.0" }
|
solana-remote-wallet = { path = "../remote-wallet", version = "=1.9.0" }
|
||||||
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
solana-sdk = { path = "../sdk", version = "=1.9.0" }
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
|
@ -370,6 +370,27 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_niceness_adjustment_valid<T>(value: T) -> Result<(), String>
|
||||||
|
where
|
||||||
|
T: AsRef<str> + Display,
|
||||||
|
{
|
||||||
|
let adjustment = value.as_ref().parse::<i8>().map_err(|err| {
|
||||||
|
format!(
|
||||||
|
"error parsing niceness adjustment value '{}': {}",
|
||||||
|
value, err
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
if solana_perf::thread::is_renice_allowed(adjustment) {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(String::from(
|
||||||
|
"niceness adjustment supported only on Linux; negative adjustment \
|
||||||
|
(priority increase) requires root or CAP_SYS_NICE (see `man 7 capabilities` \
|
||||||
|
for details)",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
@ -386,4 +407,11 @@ mod tests {
|
|||||||
assert!(is_derivation("a/b").is_err());
|
assert!(is_derivation("a/b").is_err());
|
||||||
assert!(is_derivation("0/4294967296").is_err());
|
assert!(is_derivation("0/4294967296").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_is_niceness_adjustment_valid() {
|
||||||
|
assert_eq!(is_niceness_adjustment_valid("0"), Ok(()));
|
||||||
|
assert!(is_niceness_adjustment_valid("128").is_err());
|
||||||
|
assert!(is_niceness_adjustment_valid("-129").is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use solana_gossip::cluster_info::{
|
use solana_gossip::cluster_info::{
|
||||||
ClusterInfo, MAX_INCREMENTAL_SNAPSHOT_HASHES, MAX_SNAPSHOT_HASHES,
|
ClusterInfo, MAX_INCREMENTAL_SNAPSHOT_HASHES, MAX_SNAPSHOT_HASHES,
|
||||||
};
|
};
|
||||||
|
use solana_perf::thread::renice_this_thread;
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
snapshot_archive_info::SnapshotArchiveInfoGetter,
|
||||||
snapshot_config::SnapshotConfig,
|
snapshot_config::SnapshotConfig,
|
||||||
@ -48,6 +49,7 @@ impl SnapshotPackagerService {
|
|||||||
let t_snapshot_packager = Builder::new()
|
let t_snapshot_packager = Builder::new()
|
||||||
.name("snapshot-packager".to_string())
|
.name("snapshot-packager".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
|
renice_this_thread(snapshot_config.packager_thread_niceness_adj).unwrap();
|
||||||
let mut snapshot_gossip_manager = if enable_gossip_push {
|
let mut snapshot_gossip_manager = if enable_gossip_push {
|
||||||
Some(SnapshotGossipManager {
|
Some(SnapshotGossipManager {
|
||||||
cluster_info,
|
cluster_info,
|
||||||
|
@ -35,6 +35,9 @@ pub struct SnapshotConfig {
|
|||||||
|
|
||||||
/// This is the `debug_verify` parameter to use when calling `update_accounts_hash()`
|
/// This is the `debug_verify` parameter to use when calling `update_accounts_hash()`
|
||||||
pub accounts_hash_debug_verify: bool,
|
pub accounts_hash_debug_verify: bool,
|
||||||
|
|
||||||
|
// Thread niceness adjustment for snapshot packager service
|
||||||
|
pub packager_thread_niceness_adj: i8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for SnapshotConfig {
|
impl Default for SnapshotConfig {
|
||||||
@ -54,6 +57,7 @@ impl Default for SnapshotConfig {
|
|||||||
snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
snapshot_utils::DEFAULT_MAX_INCREMENTAL_SNAPSHOT_ARCHIVES_TO_RETAIN,
|
||||||
accounts_hash_use_index: false,
|
accounts_hash_use_index: false,
|
||||||
accounts_hash_debug_verify: false,
|
accounts_hash_debug_verify: false,
|
||||||
|
packager_thread_niceness_adj: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ use {
|
|||||||
solana_clap_utils::{
|
solana_clap_utils::{
|
||||||
input_parsers::{keypair_of, keypairs_of, pubkey_of, value_of},
|
input_parsers::{keypair_of, keypairs_of, pubkey_of, value_of},
|
||||||
input_validators::{
|
input_validators::{
|
||||||
is_keypair, is_keypair_or_ask_keyword, is_parsable, is_pow2, is_pubkey,
|
is_keypair, is_keypair_or_ask_keyword, is_niceness_adjustment_valid, is_parsable,
|
||||||
is_pubkey_or_keypair, is_slot, is_valid_percentage,
|
is_pow2, is_pubkey, is_pubkey_or_keypair, is_slot, is_valid_percentage,
|
||||||
},
|
},
|
||||||
keypair::SKIP_SEED_PHRASE_VALIDATION_ARG,
|
keypair::SKIP_SEED_PHRASE_VALIDATION_ARG,
|
||||||
},
|
},
|
||||||
@ -910,6 +910,16 @@ pub fn main() {
|
|||||||
.default_value(default_maximum_incremental_snapshot_archives_to_retain)
|
.default_value(default_maximum_incremental_snapshot_archives_to_retain)
|
||||||
.help("The maximum number of incremental snapshot archives to hold on to when purging older snapshots.")
|
.help("The maximum number of incremental snapshot archives to hold on to when purging older snapshots.")
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("snapshot_packager_niceness_adj")
|
||||||
|
.long("snapshot-packager-niceness-adjustment")
|
||||||
|
.value_name("ADJUSTMENT")
|
||||||
|
.takes_value(true)
|
||||||
|
.validator(is_niceness_adjustment_valid)
|
||||||
|
.default_value("0")
|
||||||
|
.help("Add this value to niceness of snapshot packager thread. Negative value \
|
||||||
|
increases priority, positive value decreases priority.")
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("minimal_snapshot_download_speed")
|
Arg::with_name("minimal_snapshot_download_speed")
|
||||||
.long("minimal-snapshot-download-speed")
|
.long("minimal-snapshot-download-speed")
|
||||||
@ -2328,6 +2338,8 @@ pub fn main() {
|
|||||||
value_t_or_exit!(matches, "maximum_full_snapshots_to_retain", usize);
|
value_t_or_exit!(matches, "maximum_full_snapshots_to_retain", usize);
|
||||||
let maximum_incremental_snapshot_archives_to_retain =
|
let maximum_incremental_snapshot_archives_to_retain =
|
||||||
value_t_or_exit!(matches, "maximum_incremental_snapshots_to_retain", usize);
|
value_t_or_exit!(matches, "maximum_incremental_snapshots_to_retain", usize);
|
||||||
|
let snapshot_packager_niceness_adj =
|
||||||
|
value_t_or_exit!(matches, "snapshot_packager_niceness_adj", i8);
|
||||||
let minimal_snapshot_download_speed =
|
let minimal_snapshot_download_speed =
|
||||||
value_t_or_exit!(matches, "minimal_snapshot_download_speed", f32);
|
value_t_or_exit!(matches, "minimal_snapshot_download_speed", f32);
|
||||||
let maximum_snapshot_download_abort =
|
let maximum_snapshot_download_abort =
|
||||||
@ -2395,6 +2407,7 @@ pub fn main() {
|
|||||||
maximum_incremental_snapshot_archives_to_retain,
|
maximum_incremental_snapshot_archives_to_retain,
|
||||||
accounts_hash_use_index: validator_config.accounts_db_use_index_hash_calculation,
|
accounts_hash_use_index: validator_config.accounts_db_use_index_hash_calculation,
|
||||||
accounts_hash_debug_verify: validator_config.accounts_db_test_hash_calculation,
|
accounts_hash_debug_verify: validator_config.accounts_db_test_hash_calculation,
|
||||||
|
packager_thread_niceness_adj: snapshot_packager_niceness_adj,
|
||||||
});
|
});
|
||||||
|
|
||||||
validator_config.accounts_hash_interval_slots =
|
validator_config.accounts_hash_interval_slots =
|
||||||
|
Reference in New Issue
Block a user