Allow contact debug interval to be adjusted (#13737)

This commit is contained in:
sakridge
2020-11-20 14:47:37 -08:00
committed by GitHub
parent ed82bf70f5
commit c1eb350c47
3 changed files with 28 additions and 6 deletions

View File

@ -107,6 +107,7 @@ const MAX_PRUNE_DATA_NODES: usize = 32;
const GOSSIP_PING_TOKEN_SIZE: usize = 32;
const GOSSIP_PING_CACHE_CAPACITY: usize = 16384;
const GOSSIP_PING_CACHE_TTL: Duration = Duration::from_secs(640);
pub const DEFAULT_CONTACT_DEBUG_INTERVAL: u64 = 10_000;
#[derive(Debug, PartialEq, Eq)]
pub enum ClusterInfoError {
@ -298,6 +299,7 @@ pub struct ClusterInfo {
stats: GossipStats,
socket: UdpSocket,
local_message_pending_push_queue: RwLock<Vec<(CrdsValue, u64)>>,
contact_debug_interval: u64,
}
impl Default for ClusterInfo {
@ -553,6 +555,7 @@ impl ClusterInfo {
stats: GossipStats::default(),
socket: UdpSocket::bind("0.0.0.0:0").unwrap(),
local_message_pending_push_queue: RwLock::new(vec![]),
contact_debug_interval: DEFAULT_CONTACT_DEBUG_INTERVAL,
};
{
let mut gossip = me.gossip.write().unwrap();
@ -586,9 +589,14 @@ impl ClusterInfo {
.unwrap()
.clone(),
),
contact_debug_interval: self.contact_debug_interval,
}
}
pub fn set_contact_debug_interval(&mut self, new: u64) {
self.contact_debug_interval = new;
}
pub fn update_contact_info<F>(&self, modify: F)
where
F: FnOnce(&mut ContactInfo),
@ -1792,7 +1800,9 @@ impl ClusterInfo {
loop {
let start = timestamp();
thread_mem_usage::datapoint("solana-gossip");
if start - last_contact_info_trace > 10000 {
if self.contact_debug_interval != 0
&& start - last_contact_info_trace > self.contact_debug_interval
{
// Log contact info every 10 seconds
info!(
"\n{}\n\n{}",

View File

@ -3,7 +3,7 @@
use crate::{
broadcast_stage::BroadcastStageType,
cache_block_time_service::{CacheBlockTimeSender, CacheBlockTimeService},
cluster_info::{ClusterInfo, Node},
cluster_info::{ClusterInfo, Node, DEFAULT_CONTACT_DEBUG_INTERVAL},
cluster_info_vote_listener::VoteTracker,
completed_data_sets_service::CompletedDataSetsService,
consensus::{reconcile_blockstore_roots_with_tower, Tower},
@ -105,6 +105,7 @@ pub struct ValidatorConfig {
pub cuda: bool,
pub require_tower: bool,
pub debug_keys: Option<Arc<HashSet<Pubkey>>>,
pub contact_debug_interval: u64,
}
impl Default for ValidatorConfig {
@ -140,6 +141,7 @@ impl Default for ValidatorConfig {
cuda: false,
require_tower: false,
debug_keys: None,
contact_debug_interval: DEFAULT_CONTACT_DEBUG_INTERVAL,
}
}
}
@ -333,10 +335,9 @@ impl Validator {
}
}
let cluster_info = Arc::new(ClusterInfo::new(
node.info.clone(),
identity_keypair.clone(),
));
let mut cluster_info = ClusterInfo::new(node.info.clone(), identity_keypair.clone());
cluster_info.set_contact_debug_interval(config.contact_debug_interval);
let cluster_info = Arc::new(cluster_info);
let mut block_commitment_cache = BlockCommitmentCache::default();
block_commitment_cache.initialize_slots(bank.slot());
let block_commitment_cache = Arc::new(RwLock::new(block_commitment_cache));