add --no-os-network-stats-reporting option (backport #21296) (#21303)

* add --no-os-network-stats-reporting option (#21296)

(cherry picked from commit d5de0c8e12)

# Conflicts:
#	core/src/system_monitor_service.rs
#	ledger-tool/src/main.rs
#	validator/src/main.rs

* resolve merge conflicts

Co-authored-by: Jeff Biseda <jbiseda@gmail.com>
This commit is contained in:
mergify[bot]
2021-11-16 23:00:54 +00:00
committed by GitHub
parent d291bcf26e
commit 064cce41f7
4 changed files with 25 additions and 13 deletions

View File

@ -95,12 +95,12 @@ pub fn verify_udp_stats_access() -> Result<(), String> {
} }
impl SystemMonitorService { impl SystemMonitorService {
pub fn new(exit: Arc<AtomicBool>) -> Self { pub fn new(exit: Arc<AtomicBool>, report_os_network_stats: bool) -> Self {
info!("Starting SystemMonitorService"); info!("Starting SystemMonitorService");
let thread_hdl = Builder::new() let thread_hdl = Builder::new()
.name("system-monitor".to_string()) .name("system-monitor".to_string())
.spawn(move || { .spawn(move || {
Self::run(exit); Self::run(exit, report_os_network_stats);
}) })
.unwrap(); .unwrap();
@ -173,21 +173,19 @@ impl SystemMonitorService {
); );
} }
pub fn run(exit: Arc<AtomicBool>) { pub fn run(exit: Arc<AtomicBool>, report_os_network_stats: bool) {
let mut udp_stats = None; let mut udp_stats = None;
let mut now = Instant::now(); let mut now = Instant::now();
loop { loop {
if exit.load(Ordering::Relaxed) { if exit.load(Ordering::Relaxed) {
break; break;
} }
if now.elapsed() >= SAMPLE_INTERVAL { if now.elapsed() >= SAMPLE_INTERVAL {
now = Instant::now(); now = Instant::now();
if report_os_network_stats {
SystemMonitorService::process_udp_stats(&mut udp_stats); SystemMonitorService::process_udp_stats(&mut udp_stats);
} }
}
sleep(SLEEP_INTERVAL); sleep(SLEEP_INTERVAL);
} }
} }

View File

@ -141,6 +141,7 @@ pub struct ValidatorConfig {
pub bpf_jit: bool, pub bpf_jit: bool,
pub send_transaction_service_config: send_transaction_service::Config, pub send_transaction_service_config: send_transaction_service::Config,
pub no_poh_speed_test: bool, pub no_poh_speed_test: bool,
pub no_os_network_stats_reporting: bool,
pub poh_pinned_cpu_core: usize, pub poh_pinned_cpu_core: usize,
pub poh_hashes_per_batch: u64, pub poh_hashes_per_batch: u64,
pub account_indexes: AccountSecondaryIndexes, pub account_indexes: AccountSecondaryIndexes,
@ -199,6 +200,7 @@ impl Default for ValidatorConfig {
bpf_jit: false, bpf_jit: false,
send_transaction_service_config: send_transaction_service::Config::default(), send_transaction_service_config: send_transaction_service::Config::default(),
no_poh_speed_test: true, no_poh_speed_test: true,
no_os_network_stats_reporting: true,
poh_pinned_cpu_core: poh_service::DEFAULT_PINNED_CPU_CORE, poh_pinned_cpu_core: poh_service::DEFAULT_PINNED_CPU_CORE,
poh_hashes_per_batch: poh_service::DEFAULT_HASHES_PER_BATCH, poh_hashes_per_batch: poh_service::DEFAULT_HASHES_PER_BATCH,
account_indexes: AccountSecondaryIndexes::default(), account_indexes: AccountSecondaryIndexes::default(),
@ -431,11 +433,16 @@ impl Validator {
*start_progress.write().unwrap() = ValidatorStartProgress::StartingServices; *start_progress.write().unwrap() = ValidatorStartProgress::StartingServices;
if !config.no_os_network_stats_reporting {
verify_udp_stats_access().unwrap_or_else(|err| { verify_udp_stats_access().unwrap_or_else(|err| {
error!("Failed to access UDP stats: {}", err); error!("Failed to access UDP stats: {}. Bypass check with --no-os-network-stats-reporting.", err);
abort(); abort();
}); });
let system_monitor_service = Some(SystemMonitorService::new(Arc::clone(&exit))); }
let system_monitor_service = Some(SystemMonitorService::new(
Arc::clone(&exit),
!config.no_os_network_stats_reporting,
));
let leader_schedule_cache = Arc::new(leader_schedule_cache); let leader_schedule_cache = Arc::new(leader_schedule_cache);
let bank = bank_forks.working_bank(); let bank = bank_forks.working_bank();

View File

@ -45,6 +45,7 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
bpf_jit: config.bpf_jit, bpf_jit: config.bpf_jit,
send_transaction_service_config: config.send_transaction_service_config.clone(), send_transaction_service_config: config.send_transaction_service_config.clone(),
no_poh_speed_test: config.no_poh_speed_test, no_poh_speed_test: config.no_poh_speed_test,
no_os_network_stats_reporting: config.no_os_network_stats_reporting,
poh_pinned_cpu_core: config.poh_pinned_cpu_core, poh_pinned_cpu_core: config.poh_pinned_cpu_core,
account_indexes: config.account_indexes.clone(), account_indexes: config.account_indexes.clone(),
accounts_db_caching_enabled: config.accounts_db_caching_enabled, accounts_db_caching_enabled: config.accounts_db_caching_enabled,

View File

@ -1430,6 +1430,11 @@ pub fn main() {
.default_value("100") .default_value("100")
.help("Number of slots between generating accounts hash."), .help("Number of slots between generating accounts hash."),
) )
.arg(
Arg::with_name("no_os_network_stats_reporting")
.long("no-os-network-stats-reporting")
.help("Disable reporting of OS network statistics.")
)
.arg( .arg(
Arg::with_name("snapshot_version") Arg::with_name("snapshot_version")
.long("snapshot-version") .long("snapshot-version")
@ -2503,6 +2508,7 @@ pub fn main() {
), ),
}, },
no_poh_speed_test: matches.is_present("no_poh_speed_test"), no_poh_speed_test: matches.is_present("no_poh_speed_test"),
no_os_network_stats_reporting: matches.is_present("no_os_network_stats_reporting"),
poh_pinned_cpu_core: value_of(&matches, "poh_pinned_cpu_core") poh_pinned_cpu_core: value_of(&matches, "poh_pinned_cpu_core")
.unwrap_or(poh_service::DEFAULT_PINNED_CPU_CORE), .unwrap_or(poh_service::DEFAULT_PINNED_CPU_CORE),
poh_hashes_per_batch: value_of(&matches, "poh_hashes_per_batch") poh_hashes_per_batch: value_of(&matches, "poh_hashes_per_batch")