Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change peer_manager not to recompute routing multiple times #3891

Merged
merged 3 commits into from
Feb 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions chain/network/src/peer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ pub struct PeerManagerActor {
txns_since_last_block: Arc<AtomicUsize>,
pending_incoming_connections_counter: Arc<AtomicUsize>,
peer_counter: Arc<AtomicUsize>,
scheduled_routing_table_update: bool,
}

impl PeerManagerActor {
Expand Down Expand Up @@ -194,6 +195,7 @@ impl PeerManagerActor {
txns_since_last_block,
pending_incoming_connections_counter: Arc::new(AtomicUsize::new(0)),
peer_counter: Arc::new(AtomicUsize::new(0)),
scheduled_routing_table_update: false,
})
}

Expand Down Expand Up @@ -568,18 +570,22 @@ impl PeerManagerActor {
let ProcessEdgeResult { new_edge, schedule_computation } =
self.routing_table.process_edges(edges);

if let Some(duration) = schedule_computation {
near_performance_metrics::actix::run_later(
ctx,
file!(),
line!(),
duration,
|act, _ctx| {
act.routing_table.update();
#[cfg(feature = "metric_recorder")]
act.metric_recorder.set_graph(act.routing_table.get_raw_graph())
},
);
if self.scheduled_routing_table_update == false {
pmnoxx marked this conversation as resolved.
Show resolved Hide resolved
if let Some(duration) = schedule_computation {
self.scheduled_routing_table_update = true;
near_performance_metrics::actix::run_later(
ctx,
file!(),
line!(),
duration,
|act, _ctx| {
act.scheduled_routing_table_update = false;
act.routing_table.update();
#[cfg(feature = "metric_recorder")]
act.metric_recorder.set_graph(act.routing_table.get_raw_graph())
},
);
}
}

new_edge
Expand Down