-
Notifications
You must be signed in to change notification settings - Fork 780
Send flights of handshake messages in single message #2120
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
Conversation
Benchmark resultsInstruction countsSignificant differencesClick to expand
Other differencesClick to expand
Wall-timeSignificant differencesClick to expand
Other differencesClick to expand
Additional informationCheckout details:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2120 +/- ##
==========================================
- Coverage 94.66% 94.64% -0.03%
==========================================
Files 102 102
Lines 23450 23415 -35
==========================================
- Hits 22198 22160 -38
- Misses 1252 1255 +3 ☔ View full report in Codecov by Sentry. |
4fd718d to
43330bd
Compare
cpu
left a comment
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 is really nice, outside of any perf benefits I think it has an improvement on the overall readability/structure of the code.
| "Ok(BlockedHandshake)", | ||
| "Ok(BlockedHandshake)", | ||
| "Ok(BlockedHandshake)", |
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.
it's interesting to observe the optimization so directly in this API's expected states 👍
| } | ||
| } | ||
|
|
||
| pub(crate) type HandshakeFlightTls12<'a> = HandshakeFlight<'a, false>; |
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 the TLS 1.2 use-case landed alongside the new types to avoid dead code warnings? I think this diff would be easier to digest if it were separated out like the TLS 1.3 case but I wager that might produce warnings and I don't feel very strongly.
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.
In general, not sure I'm convinced of the benefit of this type alias.
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 think the type alias is mildly useful in so much as false in the generic bound doesn't clearly map to TLS1.2 without doing a bit of digging around.
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 I would like to avoid the true/false thing leaking out of this file, as far as possible.
My second choice would be to stop this type being generic like this, and just have two different constructors (eg, new_tls12(), new_tls13() or similar) and rely on everything being inlined into their uses.
| } | ||
| } | ||
|
|
||
| pub(crate) struct HandshakeFlight<'a, const TLS13: bool> { |
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 briefly considered the restrictiveness of the const generic bool here vs something more expressive but decided it was premature optimization and this seems quite reasonable after all.
| transfer(&mut client, &mut server); | ||
| server.process_new_packets().unwrap(); | ||
| { | ||
| let mut pipe = OtherSession::new(&mut client); |
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.
Nice to see the improvements reflected here too 🚀
djc
left a comment
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 looks great!
| } | ||
| } | ||
|
|
||
| pub(crate) type HandshakeFlightTls12<'a> = HandshakeFlight<'a, false>; |
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.
In general, not sure I'm convinced of the benefit of this type alias.
Agreed, -11 lines for an efficiency improvement seems like a really good deal. |
This will only have any positive effect with client auth.
43330bd to
46204e6
Compare
This is generally only valuable for TLS1.3, where we're saving encryption overheads several times over. For TLS1.2 there are no encrypted handshake messages, so we're only saving 20 bytes on the wire in the server -> client direction.
fixes #2041