Skip to content

Commit 61b31ab

Browse files
committed
reduce PullRequest intensity
1 parent 79be8c9 commit 61b31ab

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gossip/src/cluster_info.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ const DEFAULT_EPOCH_DURATION: Duration =
105105
Duration::from_millis(DEFAULT_SLOTS_PER_EPOCH * DEFAULT_MS_PER_SLOT);
106106
/// milliseconds we sleep for between gossip requests
107107
pub const GOSSIP_SLEEP_MILLIS: u64 = 100;
108+
/// Interval between pull requests
109+
const PULL_REQUEST_INTERVAL: Duration = Duration::from_millis(500);
110+
108111
/// Capacity for the [`ClusterInfo::run_socket_consume`] and [`ClusterInfo::run_listen`]
109112
/// intermediate packet batch buffers.
110113
///
@@ -1468,7 +1471,7 @@ impl ClusterInfo {
14681471
let mut last_contact_info_save = timestamp();
14691472
let mut entrypoints_processed = false;
14701473
let recycler = PacketBatchRecycler::default();
1471-
let mut generate_pull_requests = true;
1474+
let mut last_pull_request = Instant::now();
14721475
while !exit.load(Ordering::Relaxed) {
14731476
let start = timestamp();
14741477
if self.contact_debug_interval != 0
@@ -1494,6 +1497,11 @@ impl ClusterInfo {
14941497
.map(EpochSpecs::current_epoch_staked_nodes)
14951498
.cloned()
14961499
.unwrap_or_default();
1500+
let generate_pull_requests =
1501+
last_pull_request.elapsed() > PULL_REQUEST_INTERVAL;
1502+
if generate_pull_requests {
1503+
last_pull_request = Instant::now();
1504+
}
14971505
let _ = self.run_gossip(
14981506
&thread_pool,
14991507
gossip_validators.as_ref(),
@@ -1525,7 +1533,6 @@ impl ClusterInfo {
15251533
let time_left = GOSSIP_SLEEP_MILLIS - elapsed;
15261534
sleep(Duration::from_millis(time_left));
15271535
}
1528-
generate_pull_requests = !generate_pull_requests;
15291536
}
15301537
})
15311538
.unwrap()

0 commit comments

Comments
 (0)