Closed abizjak closed 3 years ago
Hi Ales, your analysis is right.
The waitStream
function is a helper that only knows about individual streams.
And typically a background job https://github.com/lucasdicioccio/http2-client-exe/blob/master/app/Main.hs#L227-L230 or
https://github.com/lucasdicioccio/http2-client-grpc/blob/master/src/Network/GRPC/Client/Helpers.hs#L54 ) is a simplistic way to solve the issue.
As far as Helpers are concerned, I'm not sure what the best approach is yet (modify waitStream
here, provide another implementation here, or another implementation in the http2-grpc
library). However I do not mind complexifying these modules as it is the right layer to "hide" this sort of complexity.
Will look at your PR to check if it double-counts the flow-control (i admit i don't remember all details either). If i remember right the library already records the per-connection flow-control credit.
Hi, thanks for the prompt response.
I think you are right that my PR is double counting the flow since creditDataFrames
is called in the main loop already, and that seems to credit the connection flow for each data frame already,.
UPDATE: I've amended the PR with this.
I'll preface the issue with a caveat that my understanding of http2 flow control is fairly limited.
The
Network.HTTP2.Client.Helpers.waitStream
function only seems to sendWINDOW_UPDATE
frames for the specific stream, but not for the connection. It is my understanding that both need to be done separately, and I have experienced blocking behaviour because of this, concretely in connection withhttp2-grpc-haskell
and itssingleRequest
function. This is a quote from RFC 7540, section 6.9.1Since
waitStream
itself does not send WINDOW_UPDATE frames for the connection, in order for the stream itself to progress an external entity must be sending these updates. In the case ofhttp2-grpc-haskell
that is handled by a background thread, but the problem with that is that it is either wasteful ifgrpcClientConfigWindowUpdateDelay
is set too low, or the latency is needlessly high if set too high.I propose to add an additional argument, either
Http2Client
orIncomingFlowControl
so that thewaitStream
function would make sure to send WINDOW_UPDATE frames for the connection.If there is another way to achieve an analogous outcome then please let me know, and I suggest adding it to the documentation of the
waitStream
method.