haskell-grpc-native / http2-client

A native HTTP2 client in Haskell
BSD 3-Clause "New" or "Revised" License
43 stars 27 forks source link

Make `waitStream` update connection flow control window. #75

Closed abizjak closed 3 years ago

abizjak commented 3 years ago

From RFC 7540


   Flow control in HTTP/2 is implemented using a window kept by each
   sender on every stream.  The flow-control window is a simple integer
   value that indicates how many octets of data the sender is permitted
   to transmit; as such, its size is a measure of the buffering capacity
   of the receiver.

   Two flow-control windows are applicable: the stream flow-control
   window and the connection flow-control window.  The sender MUST NOT
   send a flow-controlled frame with a length that exceeds the space
   available in either of the flow-control windows advertised by the
   receiver.  Frames with zero length with the END_STREAM flag set (that
   is, an empty DATA frame) MAY be sent if there is no available space
   in either flow-control window.

   For flow-control calculations, the 9-octet frame header is not
   counted.

   After sending a flow-controlled frame, the sender reduces the space
   available in both windows by the length of the transmitted frame.

   The receiver of a frame sends a WINDOW_UPDATE frame as it consumes
   data and frees up space in flow-control windows.  Separate
   WINDOW_UPDATE frames are sent for the stream- and connection-level
   flow-control windows.

   A sender that receives a WINDOW_UPDATE frame updates the
   corresponding window by the amount specified in the frame.

In particular waitStream did not automatically update the connection flow control window, leading to stalls, and reliance on external updates (i.e., another background thread had to periodically send connection window updates), which is less than ideal.

Closes #74

lucasdicioccio commented 3 years ago

Looks good, would you mind: adding some Changelog entry (especially, to credit yourself).

I'll do some tests over next week and do some release (will need to bump the version). We'll need to update http2-client-exe and http2-grpc-client in a not-too-distant future.

abizjak commented 3 years ago

Yes, will do.

abizjak commented 3 years ago

I added additional documentation and a changelog entry, as well as created two PRs in the repos you mentioned

lucasdicioccio commented 3 years ago

Looks great! will need to do some manual checks before releasing but will be merging. Thanks, and making the other PRs is grand!