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

Use SSL_sendfile() from OpenSSL 3.0 in SSLSocket.sendfile when available. #99813

Open
moonsikpark opened this issue Nov 27, 2022 · 3 comments
Open
Labels
stdlib Python modules in the Lib dir topic-SSL type-feature A feature request or enhancement

Comments

@moonsikpark
Copy link
Contributor

moonsikpark commented Nov 27, 2022

Feature or enhancement

SSL_sendfile() is a function added in OpenSSL 3.0. If we use this function, we can offload TLS to the kernel, which can hugely improve performance. However, both the kernel and OpenSSL must be built with kTLS support.

I would like to prepare a PR that enables SSL_sendfile() use in SSLSocket.sendfile.

Pitch

This would enable use of kernel TLS, which will yield significant increase of TLS performance in systems with kTLS support.

Previous discussion

https://discuss.python.org/t/sslsocket-sendfile-and-kernel-tls/18886

Linked PRs

@moonsikpark moonsikpark added the type-feature A feature request or enhancement label Nov 27, 2022
@moonsikpark moonsikpark changed the title Use SSL_sendfile() from OpenSSL 3.0 when avalible. Use SSL_sendfile() from OpenSSL 3.0 in SSLSocket.sendfile when available. Nov 27, 2022
@hugovk hugovk added topic-SSL stdlib Python modules in the Lib dir labels Nov 27, 2022
@illia-v
Copy link
Contributor

illia-v commented Nov 29, 2022

@moonsikpark thanks for opening the issue. I want to let you know that I made some progress in integrating the function in September and a little bit after #96830 was merged. It will be inefficient if we spend time solving the same problem. Let me open a PR with what I have tomorrow, then we can cooperate on finalizing this.

@moonsikpark
Copy link
Contributor Author

moonsikpark commented Nov 30, 2022

@illia-v I've finished basic PoC of using SSL_sendfile() in this branch. If your progress is beyond what I've been working on, It'd be nice if you open the PR with yours :)

@illia-v
Copy link
Contributor

illia-v commented Nov 30, 2022

@illia-v I've finished basic PoC of using SSL_sendfile() in this branch. If your progress is beyond what I've been working on, It'd be nice if you open the PR with yours :)

Cool! I created #99907, please leave your feedback about it.

Comparing to your branch, my version:

  • incorporates some sendfile usage experience moved to socket.socket._sendfile_zerocopy;
  • falls back to _sendfile_use_send;
  • follows _ssl__SSLSocket_write_impl error handling;
  • does not define _ssl._SSLSocket.sendfile at all if it unavailable similarly to how os.sendfile is not always defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-SSL type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants