You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can run it with lots of small writes, or with bigger writes. Here's the CPU usage:
$ time python tls_benchmark.py big
real 0m0.248s
user 0m0.144s
sys 0m0.039s
$ time python tls_benchmark.py small
real 0m3.312s
user 0m3.217s
sys 0m0.038s
I also measured bandwidth usage (bytes received in the TCP layer of Twisted) of the two options:
big: RECEIVED TOTAL OF 1022417 bytes
small: RECEIVED TOTAL OF 23000417 bytes
Discussion
Connection.send() returns how many bytes were successfully written. And pyOpenSSL sets SSL_MODE_ENABLE_PARTIAL_WRITE. This means future send() should not be called with same bytes, but rather those past whatever the result of send() is. Initially I thought this was part of the issue, but disabling it doesn't really make a difference.
So to solve this, either pyOpenSSL has to grow a buffering layer, or this would have to be something handled in libraries using pyOpenSSL. If the latter, the performance and bandwidth implications of small send()/write() should be documented, at least.
The text was updated successfully, but these errors were encountered:
itamarst
changed the title
Performance with small send()/write() in OpenSSL.SSL.Connection
High CPU and bandwidth usage with small send()/write() in OpenSSL.SSL.Connection
Sep 13, 2023
itamarst
changed the title
High CPU and bandwidth usage with small send()/write() in OpenSSL.SSL.Connection
High CPU and bandwidth usage with small send()s in OpenSSL.SSL.Connection
Sep 13, 2023
Consider the following program:
You can run it with lots of small writes, or with bigger writes. Here's the CPU usage:
I also measured bandwidth usage (bytes received in the TCP layer of Twisted) of the two options:
Discussion
Connection.send()
returns how many bytes were successfully written. And pyOpenSSL sets SSL_MODE_ENABLE_PARTIAL_WRITE. This means futuresend()
should not be called with same bytes, but rather those past whatever the result ofsend()
is. Initially I thought this was part of the issue, but disabling it doesn't really make a difference.So to solve this, either pyOpenSSL has to grow a buffering layer, or this would have to be something handled in libraries using pyOpenSSL. If the latter, the performance and bandwidth implications of small send()/write() should be documented, at least.
The text was updated successfully, but these errors were encountered: