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

[subsystem-bench] Emulate latency for messages and requests from node #4627

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

AndreiEres
Copy link
Contributor

Fixes #4611

  • Adds latency for messages from node
  • The real delay is split in half because the original one is meant to be RTT.

@AndreiEres AndreiEres added R0-silent Changes should not be mentioned in any release notes T12-benchmarks This PR/Issue is related to benchmarking and weights. labels May 29, 2024
@AndreiEres AndreiEres requested review from sandreim and alindima May 29, 2024 09:10
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6334978

Copy link
Contributor

@alindima alindima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and seems to work

@@ -561,6 +583,7 @@ async fn emulated_peer_loop(
}
}
if let Some(message) = message {
// TODO: message.peer() is always None because it's a message from node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but not in this PR

Comment on lines 486 to 487
if self.has_latency() {
let latency = self.emulate_latency();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we could have a get_latency() which returns a Option<tokio::time::Sleep> instead of these two functions and use if let Some(latency) = peer.get_latency() {...

@@ -548,6 +566,10 @@ async fn emulated_peer_loop(
emulated_peer.rx_limiter().reap(size).await;
stats.inc_received(size);

if peer_message.is_from_node() && emulated_peer.has_latency() {
emulated_peer.emulate_latency().await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will effectively stall the peer loop for up to whatever latency/2 is configured, meaning the peer also won't send messages to the node, even if we request it to from main thread. This latency needs to be emulated in the task that is supposed to send messages from the node to the peer, see proxy_send_request method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it. Is that what you were thinking about?

@AndreiEres AndreiEres requested a review from sandreim June 27, 2024 10:06
@AndreiEres
Copy link
Contributor Author

@sandreim Could you look at the changed implementation?

if latency_ms > 0 && receiver.is_connected() {
emulate_latency(latency_ms).await;
}
tx_network.send_message_to_peer(&peer, message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still want to send to a disconnected peer ? Wouldn't the assert in send_message_to_peer trigger if peer is not connected ?

@AndreiEres AndreiEres force-pushed the AndreiEres/subsystem-bench-latency branch from 7bbc00b to 2f8647f Compare November 13, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T12-benchmarks This PR/Issue is related to benchmarking and weights.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subsystem-bench: add emulated network latency for messages and requests coming from local validator
4 participants