Perf: Optimize sending HTTP/2 frame#6337
Conversation
1125332 to
29d2048
Compare
|
[approve ci autest] |
3a7ffb0 to
689e8ac
Compare
Prior to this change, HTTP/2 was almost 30% slower than HTTP/1.1 (over TLS) on downloading a huge file (over 1GB). Improvements: - Avoid unnecessary IOBufferBlock allocation for all type of frame - Avoid unnecessary copy on sending DATA frame - Adjust IOBufferBlock size of Http2ClientSession::write_buffer Cleanups: - Decouple receiving & sending HTTP/2 Frame - Remove unnecessary SCOPED_MUTEX_LOCK
689e8ac to
11786c4
Compare
| written += iobuffer->write(this->_reader->start(), read_len); | ||
| this->_reader->consume(read_len); | ||
| } | ||
| len += written; |
There was a problem hiding this comment.
I know that we were playing with different versions of the Data frame writing. One that wrote to contiguous buffers and passed that along to SSL_write(). Another that just passed along pointers from the original buffer (iobuffer in the case) and used the block pointers directly to write to SSL_write. Did you find that performance was better with the extra intermediate copy to hopefully get bigger blocks?
PR #5897 has the logic that was testing writing to the SSL_write directly from the iobuffer blocks.
There was a problem hiding this comment.
I compared these two approaches and the first approach is so much better.
The second one looks cool because of "no copy". However, it didn't improve performance as expected.
SSL_write() is expensive than memcpy(), so reducing SSL_write() calls is key point, IMO.
There was a problem hiding this comment.
We can get rid of the memcpy() when SSL/TLS libraries provide lower APIs which slice SSL_write() functionalities.
Actually, our QUIC implementation keeps the IOBufferBlock chain to avoid memcpy(). Unfortunately, we can't take the same approach here, because it's using the EVP cipher functions directly.
trafficserver/iocore/net/quic/QUICPacketPayloadProtector_openssl.cc
Lines 30 to 84 in 504cc9f
shinrich
left a comment
There was a problem hiding this comment.
Looks good. I'm glad that we aren't losing the work we did on HTTP/2 performance improvements. What was the % performance comparison for the 1GB download after making these changes?
|
HTTP/2 performance becomes almost the same as HTTP/1.1 with this PR.
Measured total time of downloading 1GB file from local box like below. |
|
Cherry-picked to v9.0.x branch. |
Prior to this change, HTTP/2 was almost 30% slower than HTTP/1.1 (over TLS) on downloading a huge file (over 1GB).
Improvements:
Cleanups:
Another approach of #5916.
Some features like adding padding are unimplemented as is.