Skip to content

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

Closed

Description

@moonsikpark

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

Activity

  1. changed the title [-]Use `SSL_sendfile()` from OpenSSL 3.0 when avalible.[/-] [+]Use `SSL_sendfile()` from OpenSSL 3.0 in `SSLSocket.sendfile` when available.[/+] on Nov 27, 2022
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 27, 2022
  3. illia-v commented on Nov 29, 2022

    @illia-v
    Contributor

    @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.

  4. moonsikpark commented on Nov 30, 2022

    @moonsikpark
    ContributorAuthor

    @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 :)

  5. illia-v commented on Nov 30, 2022

    @illia-v
    Contributor

    @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.
  6. added a commit that references this issue on Jul 12, 2025
  7. added a commit that references this issue on Jul 12, 2025
  8. added a commit that references this issue on Jul 13, 2025
  9. added a commit that references this issue on Aug 4, 2025
  10. added a commit that references this issue on Aug 19, 2025
  11. StanFromIreland commented on Oct 13, 2025

    @StanFromIreland
    Member

    @picnixz can this be closed as completed?

  12. removed
    pendingThe issue will be closed if no feedback is provided
    on Oct 13, 2025
  13. picnixz commented on Oct 13, 2025

    @picnixz
    Member

    Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-SSLtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions