Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1d41853
Implement dynamic HTTP2 window scaling
antonfirsov Jun 25, 2021
4067443
Merge branch 'main' into http/dynamic-window-02
antonfirsov Jun 25, 2021
a3800d3
actually fix the conflict with #54437
antonfirsov Jun 25, 2021
9f50764
add comment on PING payloads
antonfirsov Jun 25, 2021
3c7c474
delete StringBuilderOutput
antonfirsov Jun 25, 2021
6eb66e9
DisableDynamicWindowSizing: fix name
antonfirsov Jun 25, 2021
4c7f3ac
make RttEstimator.MinRtt thread-safe
antonfirsov Jun 26, 2021
473139d
simplify RuntimeSettingParserTest code
antonfirsov Jun 28, 2021
f2ff4ee
respond to PING while reading CONTINUATION frames in ProcessHeadersFrame
antonfirsov Jun 28, 2021
2bf13e0
fix test
antonfirsov Jun 28, 2021
526d723
add PingBeforeContinuationFrame_Success
antonfirsov Jun 28, 2021
7362e87
WIP: SetupAutomaticPingResponse by default
antonfirsov Jun 30, 2021
4dfcfeb
WIP: SetupAutomaticPingResponse by default
antonfirsov Jun 30, 2021
6e9142b
fix Http2_PingKeepAlive formatting
antonfirsov Jun 30, 2021
e30ab75
delete manual ping response setup code
antonfirsov Jun 30, 2021
20416ac
disallow PING frames before CONTINUATION again
antonfirsov Jun 30, 2021
9f53e0a
move process-wide settings to GlobalHttpSettings & remove MaximumWind…
antonfirsov Jun 30, 2021
13d2066
cleanup defaults
antonfirsov Jun 30, 2021
e6cc7c3
nits
antonfirsov Jun 30, 2021
b89e4bc
reduce footprint of Http2StreamWindowManager & RttEstimator
antonfirsov Jun 30, 2021
1df65a2
comments
antonfirsov Jun 30, 2021
3e18b0b
allow receiving PING ACK after GOAWAY
antonfirsov Jun 30, 2021
fb3b90e
Merge branch 'main' into http/dynamic-window-02
antonfirsov Jun 30, 2021
a54dfdc
nit
antonfirsov Jun 30, 2021
dd8d2cc
defer _lastWindowUpdate = Stopwatch.GetTimestamp()
antonfirsov Jun 30, 2021
4f302c7
delete extra newlines
antonfirsov Jun 30, 2021
e4d8639
remove _respondToPing
antonfirsov Jun 30, 2021
c7761e2
Http2LoopbackConnection: allow PING ACK after GOAWAY
antonfirsov Jun 30, 2021
e23cac8
EnableTransparentPingResponse = false in Http2_PingKeepAlive
antonfirsov Jun 30, 2021
70a04c3
commit suggestion
antonfirsov Jun 30, 2021
ddd6ea1
Merge branch 'main' into http/dynamic-window-02
antonfirsov Jul 1, 2021
7b006a5
sync DiagnosticsHandler with #54437
antonfirsov Jul 1, 2021
bc2b9b5
fix build
antonfirsov Jul 1, 2021
95f9e0d
Apply suggestions
antonfirsov Jul 2, 2021
aba1735
separate _expectPingFrame and _transparentPingResponse functionality
antonfirsov Jul 2, 2021
5cbf0e1
check for _streamWindowSize < MaxStreamWindowSize before trying to ex…
antonfirsov Jul 2, 2021
cd94dcf
nit
antonfirsov Jul 5, 2021
6954f61
move DefaultInitialHttp2StreamWindowSize
antonfirsov Jul 5, 2021
6dbfa47
harden LowBandwidthDelayProduct_ClientStreamReceiveWindowStopsScaling
antonfirsov Jul 5, 2021
3009773
delete unreliable LowBandwidthDelayProduct_ClientStreamReceiveWindowS…
antonfirsov Jul 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup defaults
  • Loading branch information
antonfirsov committed Jun 30, 2021
commit 13d2066411b51aa6e1f90834846a3dcc4f8eca3d
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ internal static partial class HttpHandlerDefaults
public static readonly TimeSpan DefaultPooledConnectionIdleTimeout = TimeSpan.FromMinutes(1);
public static readonly TimeSpan DefaultExpect100ContinueTimeout = TimeSpan.FromSeconds(1);
public static readonly TimeSpan DefaultConnectTimeout = Timeout.InfiniteTimeSpan;
public const int DefaultHttp2MaxStreamWindowSize = 16 * 1024 * 1024;
public const double DefaultHttp2StreamWindowScaleThresholdMultiplier = 1.0;

// This is the default value for SocketsHttpHandler.InitialHttp2StreamWindowSize,
// which defines the value we communicate in stream SETTINGS frames.
// Should not be confused with Http2Connection.DefaultInitialWindowSize, which defines the RFC default.
// Unlike that value, DefaultInitialHttp2StreamWindowSize might be changed in the future.
public const int DefaultInitialHttp2StreamWindowSize = 65535;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ internal static class SocketsHttpHandler
// Defaults to 1.0. Higher values result in shorter window, but slower downloads.
public static double Http2StreamWindowScaleThresholdMultiplier { get; } = GetHttp2StreamWindowScaleThresholdMultiplier();

public const int DefaultHttp2MaxStreamWindowSize = 16 * 1024 * 1024;
public const double DefaultHttp2StreamWindowScaleThresholdMultiplier = 1.0;

private static int GetMaxHttp2StreamWindowSize()
{
int value = RuntimeSettingParser.ParseInt32EnvironmentVariableValue(
"DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_FLOWCONTROL_MAXSTREAMWINDOWSIZE",
HttpHandlerDefaults.DefaultHttp2MaxStreamWindowSize);
DefaultHttp2MaxStreamWindowSize);

// Disallow small values:
if (value < Http2Connection.DefaultInitialWindowSize)
if (value < HttpHandlerDefaults.DefaultInitialHttp2StreamWindowSize)
{
value = Http2Connection.DefaultInitialWindowSize;
value = HttpHandlerDefaults.DefaultInitialHttp2StreamWindowSize;
}
return value;
}
Expand All @@ -63,12 +66,12 @@ private static double GetHttp2StreamWindowScaleThresholdMultiplier()
{
double value = RuntimeSettingParser.ParseDoubleEnvironmentVariableValue(
"DOTNET_SYSTEM_NET_HTTP_SOCKETSHTTPHANDLER_FLOWCONTROL_STREAMWINDOWSCALETHRESHOLDMULTIPLIER",
HttpHandlerDefaults.DefaultHttp2StreamWindowScaleThresholdMultiplier);
DefaultHttp2StreamWindowScaleThresholdMultiplier);

// Disallow negative values:
if (value < 0)
{
value = HttpHandlerDefaults.DefaultHttp2StreamWindowScaleThresholdMultiplier;
value = DefaultHttp2StreamWindowScaleThresholdMultiplier;
}
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ internal sealed partial class Http2Connection : HttpConnectionBase, IDisposable
#endif
// The default initial window size for streams and connections according to the RFC:
// https://datatracker.ietf.org/doc/html/rfc7540#section-5.2.1
// Unlike HttpHandlerDefaults.DefaultInitialHttp2StreamWindowSize, this value should never be changed.
internal const int DefaultInitialWindowSize = 65535;

// We don't really care about limiting control flow at the connection level.
Expand Down Expand Up @@ -198,7 +199,7 @@ public async ValueTask SetupAsync()
// The connection-level window size can not be initialized by SETTINGS frames:
// https://datatracker.ietf.org/doc/html/rfc7540#section-6.9.2
// Send an initial connection-level WINDOW_UPDATE to setup the desired ConnectionWindowSize:
uint windowUpdateAmount = (ConnectionWindowSize - DefaultInitialWindowSize);
uint windowUpdateAmount = ConnectionWindowSize - DefaultInitialWindowSize;
if (NetEventSource.Log.IsEnabled()) Trace($"Initial connection-level WINDOW_UPDATE, windowUpdateAmount={windowUpdateAmount}");
FrameHeader.WriteTo(_outgoingBuffer.AvailableSpan, FrameHeader.WindowUpdateLength, FrameType.WindowUpdate, FrameFlags.None, streamId: 0);
_outgoingBuffer.Commit(FrameHeader.Size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal sealed class HttpConnectionSettings
internal IDictionary<string, object?>? _properties;

// Http2 flow control settings:
internal int _initialHttp2StreamWindowSize = Http2Connection.DefaultInitialWindowSize;
internal int _initialHttp2StreamWindowSize = HttpHandlerDefaults.DefaultInitialHttp2StreamWindowSize;

public HttpConnectionSettings()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ public int InitialHttp2StreamWindowSize
get => _settings._initialHttp2StreamWindowSize;
set
{
if (value < Http2Connection.DefaultInitialWindowSize || value > GlobalHttpSettings.SocketsHttpHandler.MaxHttp2StreamWindowSize)
if (value < HttpHandlerDefaults.DefaultInitialHttp2StreamWindowSize || value > GlobalHttpSettings.SocketsHttpHandler.MaxHttp2StreamWindowSize)
{
throw new ArgumentOutOfRangeException(
nameof(InitialHttp2StreamWindowSize),
SR.Format(SR.net_http_http2_invalidinitialstreamwindowsize, Http2Connection.DefaultInitialWindowSize,
GlobalHttpSettings.SocketsHttpHandler.MaxHttp2StreamWindowSize));
string message = SR.Format(
SR.net_http_http2_invalidinitialstreamwindowsize,
HttpHandlerDefaults.DefaultInitialHttp2StreamWindowSize,
GlobalHttpSettings.SocketsHttpHandler.MaxHttp2StreamWindowSize);

throw new ArgumentOutOfRangeException(nameof(InitialHttp2StreamWindowSize), message);
}
CheckDisposedOrStarted();
_settings._initialHttp2StreamWindowSize = value;
Expand Down