-
Notifications
You must be signed in to change notification settings - Fork 844
Avoid unnecesarry copy on POST request over HTTP/2 #5972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not (read_vio.ntodo() == 0 || this->recv_end_stream) here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.