Avoid unnecesarry copy on POST request over HTTP/2#5972
Avoid unnecesarry copy on POST request over HTTP/2#5972masaori335 merged 1 commit intoapache:masterfrom
Conversation
|
Agreed that it simplifies the logic significantly if we can always rely the on the vio's buffer. In the case of the POST data frame, can we be guaranteed that the HttpTunnel VIO is always set up when the DATA frame arrives? |
Some DATA frames (65535 bytes, the initial window size) could arrive before the HttpTunnel is set up. But it's not a problem because the payloads of these DATA frames will be written in trafficserver/proxy/http/HttpSM.cc Lines 5676 to 5680 in 8a558cb So this change just follows what the HTTP/1.1 component does. Http2Stream doesn't need to care about which buffer to write nor copy. |
|
Looks like the AuTest failures are serious. It reproduced on my local box, I'm figuring out. |
8e7d0cd to
cb027f4
Compare
e9261f5 to
b808ad3
Compare
b808ad3 to
b083694
Compare
| } | ||
| nbytes += stream->request_buffer.write(myreader, read_len); | ||
| nbytes += writer->write(myreader, read_len); | ||
| myreader->consume(nbytes); |
There was a problem hiding this comment.
Off-topic, but, consuming nbytes in the while loop looks wrong.
|
Cherry-picked to v9.0.x branch. |
|
@shinrich and I suspect this might be the root cause of the ASAN issues on Docs (and their prod). I'm doing tests right now without this on Docs. |
|
|
||
| // Try to be smart and only signal if there was additional data | ||
| int send_event = VC_EVENT_READ_READY; | ||
| if (read_vio.ntodo() == 0 || (this->recv_end_stream && this->read_vio.nbytes != INT64_MAX)) { |
There was a problem hiding this comment.
Why not (read_vio.ntodo() == 0 || this->recv_end_stream) here?
There was a problem hiding this comment.
IIRC, this is for some AuTest failures. This checks the upper layer (HttpSM/HttpTunnel) called do_io_read(this, INT64_MAX, XXXX). Yes, it's a bit unreliable. ( I should have left some comments )
Prior to this change, all of the received payloads of DATA frames are written in the buffer of Http2Stream (
request_buffer). And after HttpTunnel is set up, the data is copied to another buffer onHttp2Stream::update_read_request.It looks like we can directly write the payloads to the buffer which is created by HttpSM/HttpTunnel for the POST request.
Actually, the copy is switching chain of IOBufferBlock, so this doesn't have big performance improvement but this makes code much simpler.