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

SSL: optimize handling of packets/framing #196

Open
njsmith opened this issue Jun 11, 2017 · 0 comments
Open

SSL: optimize handling of packets/framing #196

njsmith opened this issue Jun 11, 2017 · 0 comments
Labels
polish TLS Relevant to our TLS/SSL implementation

Comments

@njsmith
Copy link
Member

njsmith commented Jun 11, 2017

There are (at least) two subtle ways that our current SSL code is slightly inefficient:

  • Sometimes, it may happen the side the finishes the handshake is also the first to speak, and in this case it's slightly less overhead if the first data frame goes out in the same packet as the end of the handshake. (When this actually happens is complicated; it depends on which side speaks first, whether we're starting a new session or resuming and old one, and which version of TLS is in use.) What we could do is to have a kind of "cork" option, where if send_all triggers the handshake then it tells _retry to leave the last set of bytes-to-send in the buffer (if any), where they'll immediately get flushed out by the next call to _retry. (Note: this doesn't help if calling do_handshake explicitly; not sure there's much we can do about that.)

  • Currently, the user hands SSLStream.send_all chunks of data of whatever size, and then we let openssl break them into records. I believe that by default it will use the largest possible records (16 KiB). This is not necessarily the best approach. Even though ssl doesn't expose any specific knobs for this, I think each call to SSLObject.write has to generate a complete record, so we could do it by tracking the optimal record size and manually breaking data into pieces of that size before passing them to write. (Maybe with a bit of trickiness if we want to rejoin it all before calling send_all on the transport. Or maybe this doesn't really matter.)

    Also I guess if we're piggybacking on the end of a handshake, that should be taken into account when calculating the optimal size for the first record.

@njsmith njsmith added the polish label Jun 11, 2017
@oremanj oremanj added the TLS Relevant to our TLS/SSL implementation label May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polish TLS Relevant to our TLS/SSL implementation
Projects
None yet
Development

No branches or pull requests

2 participants