-
Notifications
You must be signed in to change notification settings - Fork 13
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
Batch p2p messages in one round instead of flushing immediately #127
base: m
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -715,13 +715,12 @@ where | |
) | ||
.map_err(|e| Bug::PiEnc(BugSource::psi0, e))?; | ||
|
||
tracer.send_msg(); | ||
outgoings | ||
.send(Outgoing::p2p(j, Msg::Round1b(MsgRound1b { psi0 }))) | ||
.feed(Outgoing::p2p(j, Msg::Round1b(MsgRound1b { psi0 }))) | ||
.await | ||
.map_err(IoError::send_message)?; | ||
tracer.msg_sent(); | ||
} | ||
outgoings.flush().await.map_err(IoError::send_message)?; | ||
Comment on lines
-718
to
+723
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, the only implementation of the trace trait we have does not assume that a single message actually gets sent between these calls. The time between these calls just get accounted as spent on sending messages, no matter how many were sent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ugh, ok, that's a weird metric then. But I'll put the traces back in this case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Measuring how much time we spend on sending messages in a weird metric to you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good metric. But we're not measuring it here, what we'll be measuring is time spent adding messages to a queue. I don't find it very useful, especially with a misleading name. Maybe it makes sense to add some trace to flushing though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will be measuring time spent on adding to queue + time spent on flushing items from the queue. Two of them makes the time we spend on sending messages. |
||
|
||
// Round 2 | ||
tracer.round_begins(); | ||
|
@@ -950,9 +949,8 @@ where | |
.map_err(|e| Bug::PiLog(BugSource::psi_prime, e))?; | ||
runtime.yield_now().await; | ||
|
||
tracer.send_msg(); | ||
outgoings | ||
.send(Outgoing::p2p( | ||
.feed(Outgoing::p2p( | ||
j, | ||
Msg::Round2(MsgRound2 { | ||
Gamma: Gamma_i, | ||
|
@@ -967,8 +965,8 @@ where | |
)) | ||
.await | ||
.map_err(IoError::send_message)?; | ||
tracer.msg_sent(); | ||
} | ||
outgoings.flush().await.map_err(IoError::send_message)?; | ||
|
||
// Round 3 | ||
tracer.round_begins(); | ||
|
@@ -1124,9 +1122,8 @@ where | |
) | ||
.map_err(|e| Bug::PiLog(BugSource::psi_prime_prime, e))?; | ||
|
||
tracer.send_msg(); | ||
outgoings | ||
.send(Outgoing::p2p( | ||
.feed(Outgoing::p2p( | ||
j, | ||
Msg::Round3(MsgRound3 { | ||
delta: delta_i, | ||
|
@@ -1136,8 +1133,8 @@ where | |
)) | ||
.await | ||
.map_err(IoError::send_message)?; | ||
tracer.msg_sent(); | ||
} | ||
outgoings.flush().await.map_err(IoError::send_message)?; | ||
|
||
// Output | ||
tracer.named_round_begins("Presig output"); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Is it why you added
futures
dep, to dofutures::stream::iter
? You can usefutures-util
crate instead, i.e.futures_util::stream::iter
,futures
crate just re-exports this function fromfutures-util
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.
Also, you could remove new (direct) dependency by using chain of
outgoings.feed(msg).await
inside of loop, followed byoutgoings.flush().await
.I would prefer this option, though using
futures_util::stream::iter
does have an advantage that we can't forget to call.flush().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.
I see that in other places of the protocol, you are using
feed
/flush
chain, so you can do that here as well and remove the dependencyThere 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.
I use send_all where it doesn't change existing code too much, and feed+flush where send_all would. I think send_all is better, but I have a bias to not change existing lines too much