Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

tls:send performance improvement #19

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

rraptorr commented Sep 20, 2011

Fixes the same issue that is present in exmpp TLS driver (that I've send earlier).

Also applies cleanly on 2.1.x branch.

@rraptorr rraptorr Decrease CPU usage caused by tls:send with large data.
Sending one large chunk of data with tls:send eats lots of
CPU power and blocks whole Erlang emulator. This is caused by the
fact that encrypted output is read from memory BIO in 1k chunks.
Memory BIO, after reading data, shifts the remaining part.
If large chunks of data (few MB) is sent and then read in 1k
chunks, then a _lot_ of shifting is performed eating CPU.

The solution is to simply allocate binary of the needed size
(amount of data in memory BIO can be retrieved with
BIO_ctrl_pending) and then issue only one read that reads the
whole data.
15a1dbb
Member

badlop commented Sep 24, 2011

Thanks. Patch tested and applied to both branches.

@badlop badlop closed this Sep 24, 2011

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