openssl
openssl copied to clipboard
Proposal for improving memory efficiency and speed
Background
Our system handles large data, such as images larger than 10MB. I faced something that took a few seconds in the communication part of SSL.
Proposal
The part that could be improved is the buffering logic. The logic below will generate a large string object many times if nwrote is small and wbuffer is large. https://github.com/ruby/openssl/blob/master/lib/openssl/buffering.rb#L358
@wbuffer[0, nwrote] = ""
I think it is more efficient to take a specific size from the wbuffer and write it, as follows.
I'll submit a pull request with a result of investigation for memory allocation and speed.
It might make even more sense for us to rewrite this using C and/or IO::Buffer
to experiment with performance.