-
Notifications
You must be signed in to change notification settings - Fork 725
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
base: master
Are you sure you want to change the base?
Conversation
The CI pipeline was cancelled due to failure one of the required jobs. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
if self.has_latency() { | ||
let latency = self.emulate_latency(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
@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); |
There was a problem hiding this comment.
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 ?
7bbc00b
to
2f8647f
Compare
Fixes #4611