- Notifications
You must be signed in to change notification settings - Fork5.2k
Implement dynamic HTTP/2 window scaling#54755
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
40 commits Select commitHold shift + click to select a range
1d41853 Implement dynamic HTTP2 window scaling
antonfirsov4067443 Merge branch 'main' into http/dynamic-window-02
antonfirsova3800d3 actually fix the conflict with #54437
antonfirsov9f50764 add comment on PING payloads
antonfirsov3c7c474 delete StringBuilderOutput
antonfirsov6eb66e9 DisableDynamicWindowSizing: fix name
antonfirsov4c7f3ac make RttEstimator.MinRtt thread-safe
antonfirsov473139d simplify RuntimeSettingParserTest code
antonfirsovf2ff4ee respond to PING while reading CONTINUATION frames in ProcessHeadersFrame
antonfirsov2bf13e0 fix test
antonfirsov526d723 add PingBeforeContinuationFrame_Success
antonfirsov7362e87 WIP: SetupAutomaticPingResponse by default
antonfirsov4dfcfeb WIP: SetupAutomaticPingResponse by default
antonfirsov6e9142b fix Http2_PingKeepAlive formatting
antonfirsove30ab75 delete manual ping response setup code
antonfirsov20416ac disallow PING frames before CONTINUATION again
antonfirsov9f53e0a move process-wide settings to GlobalHttpSettings & remove MaximumWind…
antonfirsov13d2066 cleanup defaults
antonfirsove6cc7c3 nits
antonfirsovb89e4bc reduce footprint of Http2StreamWindowManager & RttEstimator
antonfirsov1df65a2 comments
antonfirsov3e18b0b allow receiving PING ACK after GOAWAY
antonfirsovfb3b90e Merge branch 'main' into http/dynamic-window-02
antonfirsova54dfdc nit
antonfirsovdd8d2cc defer _lastWindowUpdate = Stopwatch.GetTimestamp()
antonfirsov4f302c7 delete extra newlines
antonfirsove4d8639 remove _respondToPing
antonfirsovc7761e2 Http2LoopbackConnection: allow PING ACK after GOAWAY
antonfirsove23cac8 EnableTransparentPingResponse = false in Http2_PingKeepAlive
antonfirsov70a04c3 commit suggestion
antonfirsovddd6ea1 Merge branch 'main' into http/dynamic-window-02
antonfirsov7b006a5 sync DiagnosticsHandler with #54437
antonfirsovbc2b9b5 fix build
antonfirsov95f9e0d Apply suggestions
antonfirsovaba1735 separate _expectPingFrame and _transparentPingResponse functionality
antonfirsov5cbf0e1 check for _streamWindowSize < MaxStreamWindowSize before trying to ex…
antonfirsovcd94dcf nit
antonfirsov6954f61 move DefaultInitialHttp2StreamWindowSize
antonfirsov6dbfa47 harden LowBandwidthDelayProduct_ClientStreamReceiveWindowStopsScaling
antonfirsov3009773 delete unreliable LowBandwidthDelayProduct_ClientStreamReceiveWindowS…
antonfirsovFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
separate _expectPingFrame and _transparentPingResponse functionality
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitaba173540a95a920b5f1069801872eae7ac5ce43
There are no files selected for viewing
68 changes: 27 additions & 41 deletionssrc/libraries/Common/tests/System/Net/Http/Http2LoopbackConnection.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -36,11 +36,12 @@ public class Http2LoopbackConnection : GenericLoopbackConnection | ||
| public Stream Stream => _connectionStream; | ||
| public Task<bool> SettingAckWaiter => _ignoredSettingsAckPromise?.Task; | ||
| private Http2LoopbackConnection(SocketWrapper socket, Stream stream, TimeSpan timeout, bool transparentPingResponse) | ||
| { | ||
| _connectionSocket = socket; | ||
| _connectionStream = stream; | ||
| _timeout = timeout; | ||
| _transparentPingResponse = transparentPingResponse; | ||
| } | ||
| public static Task<Http2LoopbackConnection> CreateAsync(SocketWrapper socket, Stream stream, Http2Options httpOptions) | ||
| @@ -78,12 +79,8 @@ public static async Task<Http2LoopbackConnection> CreateAsync(SocketWrapper sock | ||
| stream = sslStream; | ||
| } | ||
| var con = new Http2LoopbackConnection(socket, stream, timeout, httpOptions.EnableTransparentPingResponse); | ||
| await con.ReadPrefixAsync().ConfigureAwait(false); | ||
| return con; | ||
| } | ||
| @@ -204,20 +201,12 @@ public async Task<Frame> ReadFrameAsync(CancellationToken cancellationToken) | ||
| return await ReadFrameAsync(cancellationToken).ConfigureAwait(false); | ||
| } | ||
| if (header.Type == FrameType.Ping && (_expectPingFrame != null || _transparentPingResponse)) | ||
| { | ||
| PingFrame pingFrame = PingFrame.ReadFrom(header, data); | ||
| bool processed = await TryProcessExpectedPingFrameAsync(pingFrame); | ||
| return processed ? await ReadFrameAsync(cancellationToken).ConfigureAwait(false) : pingFrame; | ||
| } | ||
| // Construct the correct frame type and return it. | ||
| @@ -246,30 +235,30 @@ public async Task<Frame> ReadFrameAsync(CancellationToken cancellationToken) | ||
| } | ||
| } | ||
| private async Task<bool> TryProcessExpectedPingFrameAsync(PingFrame pingFrame) | ||
| { | ||
| if (_expectPingFrame != null) | ||
| { | ||
| _expectPingFrame.SetResult(pingFrame); | ||
| _expectPingFrame = null; | ||
| return true; | ||
| } | ||
| else if (_transparentPingResponse && !pingFrame.AckFlag) | ||
| { | ||
| bool shutdownOccured = false; | ||
| try | ||
| { | ||
| await SendPingAckAsync(pingFrame.Data); | ||
| } | ||
| catch (IOException ex) when (_expectClientDisconnect && ex.InnerException is SocketExceptionse &&se.SocketErrorCode == SocketError.Shutdown) | ||
| { | ||
| // couldn't send PING ACK, because client is already disconnected | ||
| shutdownOccured = true; | ||
| } | ||
| _transparentPingResponse = !shutdownOccured; | ||
antonfirsov marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| // Reset and return underlying networking objects. | ||
| @@ -306,25 +295,22 @@ public void IgnoreWindowUpdates() | ||
| _ignoreWindowUpdates = true; | ||
| } | ||
| // Set up loopback server to expect a PING frame among other frames. | ||
| // Once PING frame is read in ReadFrameAsync, the returned task is completed. | ||
| // The returned task is canceled in ReadPingAsync if no PING frame has been read so far. | ||
| // Does not work when Http2Options.EnableTransparentPingResponse == true | ||
| public Task<PingFrame> ExpectPingFrameAsync() | ||
| { | ||
| if (_transparentPingResponse) | ||
| { | ||
| throw new InvalidOperationException( | ||
| $"{nameof(Http2LoopbackConnection)}.{nameof(ExpectPingFrameAsync)} can not be used when transparent PING response is enabled."); | ||
| } | ||
| _expectPingFrame ??= new TaskCompletionSource<PingFrame>(); | ||
| return _expectPingFrame.Task; | ||
| } | ||
| public async Task ReadRstStreamAsync(int streamId) | ||
| { | ||
| Frame frame = await ReadFrameAsync(_timeout); | ||
1 change: 0 additions & 1 deletionsrc/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.