Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Implement HTTP/2 input flow control#2740

Merged
halter73 merged 8 commits into
release/2.2from
halter73/2710
Jul 27, 2018
Merged

Implement HTTP/2 input flow control#2740
halter73 merged 8 commits into
release/2.2from
halter73/2710

Conversation

@halter73
Copy link
Copy Markdown
Member

@halter73 halter73 requested review from Tratcher and davidfowl July 20, 2018 02:52
Copy link
Copy Markdown
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

No major blockers.

{
_flow = new Http2FlowControl(initialWindowSize);
_initialWindowSize = (int)initialWindowSize;
_minWindowSizeIncrement = _initialWindowSize / 2;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

32kb? That seems high when TLS frames are limited to 16kb. 8-16kb?

I know you're not exposing settings yet, but do you want to plum this through as a parameter now so it will be easier to configure later?


using System.Diagnostics;

namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
Copy link
Copy Markdown
Member

@Tratcher Tratcher Jul 20, 2018

Choose a reason for hiding this comment

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

Http2.FlowControl to match the directory?


namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
{
public class Http2StreamInputFlowControl
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

StreamInputFlowControl? No need to include Http2 in all the type names when it's in the namespace there's nothing to disambiguate against (e.g. Http2Connection and Http2Stream make sense, but most of these others don't need it).

if (streamWindowUpdateSize > 0)
{
// Writing with the FrameWriter should only fail if given a canceled token, so just fire and forget.
_ = _frameWriter.WriteWindowUpdateAsync(_streamId, streamWindowUpdateSize);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any way to batch stream window updates and connection window updates into the same write operation? A connection window update will primarily be triggered by a stream update right? (With the exception of a stream abort?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Stream and connection window updates will only happen at the same time when there's only one stream. With multiple streams, the windows get out of sync. Once we introduce a different window size for the connection vs the streams, the windows won't even be in sync in the one stream scenario.

_context.OnDataRead(bytesRead);
}

// REVIEW: Can an app partially consume the request body in a non-aborted stream? Write a test.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

RequestBodyPipe.Writer.Complete(new IOException(CoreStrings.Http2StreamAborted, abortReason));

// Stop counting any buffered bytes for this stream towards the connection input flow-control window.
_inputFlowControl.Abort();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to update the connection flow control.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It does internally.

@halter73
Copy link
Copy Markdown
Member Author

⬆️📅

@halter73
Copy link
Copy Markdown
Member Author

@dotnet-bot test OSX 10.12 Release Build

public bool EndStreamReceived { get; private set; }

protected IHttp2StreamLifetimeHandler StreamLifetimeHandler => _context.StreamLifetimeHandler;
public bool EndStreamReceived => (_completionState & StreamCompletionFlags.EndStreamReceived) == StreamCompletionFlags.EndStreamReceived;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see what you meant by wanting to use HasFlag

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's wrong with HasFlag? Is an intrinsic now dotnet/coreclr#13748

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That change is what got us talking about HasFlag. We don't want to rely on CoreCLR-only intrinsics yet. In this case, you could argue it's OK since the desktop framework doesn't support ALPN, but we'd rather switch to using HasFlag all at once.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The method exists in desktop though? Its just slower?

Copy link
Copy Markdown
Member Author

@halter73 halter73 Jul 27, 2018

Choose a reason for hiding this comment

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

Yep. The desktop version of HasFlag does reflection each time IIRC.

@halter73 halter73 merged commit 94cfc01 into release/2.2 Jul 27, 2018
@halter73 halter73 deleted the halter73/2710 branch July 27, 2018 17:47
var lastCompletionState = _completionState;
_completionState |= completionState;

if (ShoulStopTrackingStream(_completionState) && !ShoulStopTrackingStream(lastCompletionState))
Copy link
Copy Markdown
Contributor

@benaadams benaadams Jul 27, 2018

Choose a reason for hiding this comment

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

Missing d
ShoulStopTrackingStream
ShouldStopTrackingStream

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants