-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Avoid unnecessary flushes for unary responses #4884
Comments
@ejona86 following up on this. Was this issue (of responding with multiple packets) discussed / mitigated in some way? |
Nothing has changed here. You can contribute, but IIRC part of the trouble here is how trailers are plumbed in the internals. We might need to detect this case directly in Netty, similar to sending headers on client-side. |
This is improved with #9273, but response headers are still a separate packet, so reopening. |
@ejona86 do you have any explanation why this change doesn't reduce the number of packets sent? |
There's WINDOW_UPDATE and potentially PING. That flush is because |
@ejona86, @ohadgur and me did some research and apparently the extra packets are PINGs. The reason is that |
I'd be happy to have some approach to limit the number of PINGs. I'm not entirely wild about the approaches I've heard C core and .Net do. I think I'd go with the approach of "delay the ping by the BDP bytes for every monitor PING that hasn't increased the window." Up to some limit (10?). Assuming the connection is saturated, initially we'd do a PING every RTT, and then we'd do it approximately 2RTT, 3RTT, until 11*RTT. (The +1 RTT here is because I am describing the time between PINGs and that includes the time it takes for the PING ack to be received.) We can also limit the minimum BDP used for the delay to 64 KB to reduce unnecessary pings on most unsaturated links. |
@amirhadadi from lengthy exchange at #8260 this seems to be a "feature" and appears working as intended. Also It looks like mentioned issue was renamed by maintainers to something obscurely vague, but in short after #7446 was introduced having up to 1000 PINGS/second /w autoflowControl is a new norm. |
It is definitely a feature. Without it, in some not-that-rare of scenarios, you could be getting < 2% of the available throughput from a connection. And I would actually agree it is too aggressive. My pushing back on #8260 was much more to determine whether it was "someone stumbled across it and thought to themselves, that seems ineffecient" which isn't all interesting or whether it was "something was going wrong such that the overly aggressive behavior was noticed." This issue is a case where "something was going wrong." Normally we try to delay flushes and the like, but the timing is actually sensitive here. (Originally the design had chosen to send the PINGs along with connection WINDOW_UPDATES, which would have avoided the flush. But that fails to notice any bytes in some semi-trivial scenarios.) |
We currently optimize flushes for unary requests on client-side, by delaying flushing until the end of the RPC. When looking at the code, I realized it doesn't appear we're doing that for server-side.
Using wireshare with the interop client/server with empty_unary, we can see a single packet for the request but three packets for the response:
We should optimize the response flow so that all three frames are sent with a single flush.
The text was updated successfully, but these errors were encountered: