Topic: Code improvement suggestion for dynamic output buffer: wolfssl-3.9.0
Hello and thanks for your work on wolfSSL!
I have one suggestion for your current code:
in the internal.c file
SendBuffered method ends with these 3 lines:
if (ssl->buffers.outputBuffer.dynamicFlag)
ShrinkOutputBuffer(ssl);
return 0;
It looks like shrinking the output buffer here is not a best idea here; I just commented out these two lines:
if (ssl->buffers.outputBuffer.dynamicFlag)
ShrinkOutputBuffer(ssl);
and got much better performance.
What you are doing right now is allocating and deleting the output buffer on every write operation. When commenting out these two lines, you will only delete and allocate when your new write needs a bigger buffer than you already have. Good optimization. This is helpful when you are sending out variable-size chunks. Also, it allows us to send directly from your output buffer (we are using callbacks, of course, for reading and for writing, because we use overlapped socket IO with completion ports). With the current code one must copy from your output buffer to his own buffer inside of his write callback.
Hope this makes sense to you and please correct me if I am wrong.
Dude 777