Skip to content

Commit

Permalink
Allow contact debug interval to be adjusted (solana-labs#13737)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge authored Nov 20, 2020
1 parent ed82bf7 commit c1eb350
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
12 changes: 11 additions & 1 deletion core/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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{}",
Expand Down
11 changes: 6 additions & 5 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -140,6 +141,7 @@ impl Default for ValidatorConfig {
cuda: false,
require_tower: false,
debug_keys: None,
contact_debug_interval: DEFAULT_CONTACT_DEBUG_INTERVAL,
}
}
}
Expand Down Expand Up @@ -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));
Expand Down
11 changes: 11 additions & 0 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,14 @@ pub fn main() {
.help("Number of slots between generating snapshots, \
0 to disable snapshots"),
)
.arg(
Arg::with_name("contact_debug_interval")
.long("contact-debug-interval")
.value_name("CONTACT_DEBUG_INTERVAL")
.takes_value(true)
.default_value("10000")
.help("Milliseconds between printing contact debug from gossip."),
)
.arg(
Arg::with_name("accounts_hash_interval_slots")
.long("accounts-hash-slots")
Expand Down Expand Up @@ -1435,6 +1443,8 @@ pub fn main() {
bind_address
};

let contact_debug_interval = value_t_or_exit!(matches, "contact_debug_interval", u64);

let restricted_repair_only_mode = matches.is_present("restricted_repair_only_mode");
let mut validator_config = ValidatorConfig {
require_tower: matches.is_present("require_tower"),
Expand Down Expand Up @@ -1499,6 +1509,7 @@ pub fn main() {
wal_recovery_mode,
poh_verify: !matches.is_present("skip_poh_verify"),
debug_keys,
contact_debug_interval,
..ValidatorConfig::default()
};

Expand Down

0 comments on commit c1eb350

Please sign in to comment.