Skip to content

HTTP/2 multiplex: Correctly process buffered inbound data even if aut…#9389

Merged
normanmaurer merged 1 commit into4.1from
read_stuck
Jul 21, 2019
Merged

HTTP/2 multiplex: Correctly process buffered inbound data even if aut…#9389
normanmaurer merged 1 commit into4.1from
read_stuck

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

…oRead is false

Motivation:

When using the HTTP/2 multiplex implementation we need to ensure we correctly drain the buffered inbound data even if the RecvByteBufallocator.Handle tells us to stop reading in between.

Modifications:

Correctly loop through the buffered inbound data until the user does stop to request from it.

Result:

Fixes #9387.

Co-authored-by: Bryce Anderson banderson@twitter.com

…oRead is false

Motivation:

When using the HTTP/2 multiplex implementation we need to ensure we correctly drain the buffered inbound data even if the RecvByteBufallocator.Handle tells us to stop reading in between.

Modifications:

Correctly loop through the buffered inbound data until the user does stop to request from it.

Result:

Fixes #9387.

Co-authored-by: Bryce Anderson <banderson@twitter.com>
@bryce-anderson
Copy link
Copy Markdown
Contributor

bryce-anderson commented Jul 18, 2019

I'm testing this patch now. I'll let you know how it goes.

I have another idea that I think we should consider: perhaps we should change the behavior of the stream channels to always eagerly push messages down the pipeline and use .read() calls to trigger window updates. The application already has the bytes in memory and in the case of EOS we flush everything down the pipeline so the application already must be prepared to handle more messages that .read() calls. Therefore, eagerly flushing data may get stuff off the heap faster while still allowing back-pressure via the flow windows. It also allows us to drop the inboundBuffer and all the complexity associated with it.

Copy link
Copy Markdown
Contributor

@bryce-anderson bryce-anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it works locally. I'm a little worried that we can get into a readStatus = REQUESTED state from the fireChildRead method but it appears to be benign.

@normanmaurer
Copy link
Copy Markdown
Member Author

@bryce-anderson i „think“ it should be not a problem, hopefully I am right tho...

I also like your idea about pushing eagerly. Maybe we should merge this PR and the investigate with a followup ?

@bryce-anderson
Copy link
Copy Markdown
Contributor

Agreed on merging this and investigating the eager-pushing lazy acking strategy. 👍

normanmaurer added a commit that referenced this pull request Jul 18, 2019
…ckpressure via window update frames by read()

Motivation:

At the moment each Http2StreamChannel instance has a complicated state machine to handle auto read configurations. We can simplify this by just always fire frames to the child channel pipelines as soon as we receive them but only give back bytes to the flowcontroller when read() is called. This will ensure that backpressure still is correctly managed via flow control (by window update frames) but simplify things a lot and may release memory more quickly.

Fore more details see #9389 (comment).

Special thanks to @bryce-anderson for the idea.

Modifications:

- Remove all the complex buffering logic from AbstractHttp2StreamChannel
- Move logic to give back bytes to the flow-controller (and so produce window update frames) to beginRead(...)
- Update tests

Result:

Less complex implementation while still maintain ability to flow control channels.
@normanmaurer
Copy link
Copy Markdown
Member Author

@bryce-anderson PTAL #9390 for an implementation of your idea.

@normanmaurer normanmaurer merged commit 60cf18c into 4.1 Jul 21, 2019
normanmaurer added a commit that referenced this pull request Jul 21, 2019
…oRead is false (#9389)

Motivation:

When using the HTTP/2 multiplex implementation we need to ensure we correctly drain the buffered inbound data even if the RecvByteBufallocator.Handle tells us to stop reading in between.

Modifications:

Correctly loop through the buffered inbound data until the user does stop to request from it.

Result:

Fixes #9387.

Co-authored-by: Bryce Anderson <banderson@twitter.com>
@normanmaurer normanmaurer added this to the 4.1.38.Final milestone Jul 21, 2019
normanmaurer added a commit that referenced this pull request Oct 23, 2019
…ckpressure via window update frames by read()

Motivation:

At the moment each Http2StreamChannel instance has a complicated state machine to handle auto read configurations. We can simplify this by just always fire frames to the child channel pipelines as soon as we receive them but only give back bytes to the flowcontroller when read() is called. This will ensure that backpressure still is correctly managed via flow control (by window update frames) but simplify things a lot and may release memory more quickly.

Fore more details see #9389 (comment).

Special thanks to @bryce-anderson for the idea.

Modifications:

- Remove all the complex buffering logic from AbstractHttp2StreamChannel
- Move logic to give back bytes to the flow-controller (and so produce window update frames) to beginRead(...)
- Update tests

Result:

Less complex implementation while still maintain ability to flow control channels.
@normanmaurer normanmaurer deleted the read_stuck branch July 6, 2020 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seeing HttpDataFrame's (and maybe others) getting out of order in AbstractHttp2StreamChannel

2 participants