From 90be960f15984d745679155356a10388b8a2b984 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 26 Sep 2023 19:40:48 -0700 Subject: [PATCH] Clarify some log messages and comments --- .../Kestrel/Core/src/Internal/Http2/Http2Connection.cs | 10 ++++++---- .../Core/src/Internal/Http2/Http2FrameWriter.cs | 2 +- .../src/Internal/Infrastructure/KestrelTrace.Http2.cs | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs index 917c20ef3b7a..2a12db907c7b 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs @@ -46,13 +46,13 @@ internal sealed partial class Http2Connection : IHttp2StreamLifetimeHandler, IHt private const int MaxStreamPoolSize = 100; private const long StreamPoolExpiryTicks = TimeSpan.TicksPerSecond * 5; - private const string EnhanceYourCalmMaximumCountProperty = "Microsoft.AspNetCore.Server.Kestrel.Http2.EnhanceYourCalmCount"; + private const string MaximumEnhanceYourCalmCountProperty = "Microsoft.AspNetCore.Server.Kestrel.Http2.MaxEnhanceYourCalmCount"; - private static readonly int _enhanceYourCalmMaximumCount = GetEnhanceYourCalmMaximumCount(); + private static readonly int _enhanceYourCalmMaximumCount = GetMaximumEnhanceYourCalmCount(); - private static int GetEnhanceYourCalmMaximumCount() + private static int GetMaximumEnhanceYourCalmCount() { - var data = AppContext.GetData(EnhanceYourCalmMaximumCountProperty); + var data = AppContext.GetData(MaximumEnhanceYourCalmCountProperty); if (data is int count) { return count; @@ -1290,6 +1290,8 @@ private void AbortStream(int streamId, IOException error) void IRequestProcessor.Tick(DateTimeOffset now) { Input.CancelPendingRead(); + // We count EYCs over a window of a given length to avoid flagging short-lived bursts. + // At the end of each window, reset the count. if (IsEnhanceYourCalmEnabled && ++_tickCount % EnhanceYourCalmTickWindowCount == 0) { Interlocked.Exchange(ref _enhanceYourCalmCount, 0); diff --git a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs index 4eec37cb124a..f90f728a34fe 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http2/Http2FrameWriter.cs @@ -105,7 +105,7 @@ public Http2FrameWriter( _hpackEncoder = new DynamicHPackEncoder(serviceContext.ServerOptions.AllowResponseHeaderCompression); _maximumFlowControlQueueSize = ConfiguredMaximumFlowControlQueueSize is null - ? 4 * maxStreamsPerConnection + ? 4 * maxStreamsPerConnection // 4 is a magic number to give us some padding above the expected maximum size : (int)ConfiguredMaximumFlowControlQueueSize; if (IsMaximumFlowControlQueueSizeEnabled && _maximumFlowControlQueueSize < maxStreamsPerConnection) diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs index 9a7f7dbdfdd5..c9c3c9f55b83 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelTrace.Http2.cs @@ -146,13 +146,13 @@ private static partial class Http2Log // Highest shared ID is 63. New consecutive IDs start at 64 - [LoggerMessage(64, LogLevel.Debug, @"Connection id ""{ConnectionId}"" aborted since at least ""{Count}"" ENHANCE_YOUR_CALM responses were required per second.", EventName = "Http2TooManyEnhanceYourCalms")] + [LoggerMessage(64, LogLevel.Debug, @"Connection id ""{ConnectionId}"" aborted since at least {Count} ENHANCE_YOUR_CALM responses were recorded per second.", EventName = "Http2TooManyEnhanceYourCalms")] public static partial void Http2TooManyEnhanceYourCalms(ILogger logger, string connectionId, int count); - [LoggerMessage(65, LogLevel.Debug, @"Connection id ""{ConnectionId}"" exceeded the output flow control maximum queue size of ""{Count}"".", EventName = "Http2FlowControlQueueOperationsExceeded")] + [LoggerMessage(65, LogLevel.Debug, @"Connection id ""{ConnectionId}"" exceeded the output flow control maximum queue size of {Count}.", EventName = "Http2FlowControlQueueOperationsExceeded")] public static partial void Http2FlowControlQueueOperationsExceeded(ILogger logger, string connectionId, int count); - [LoggerMessage(66, LogLevel.Debug, @"Connection id ""{ConnectionId}"" configured maximum flow control queue size ""{Actual}"" is less than the maximum streams per connection ""{Expected}"" - increasing to match.", EventName = "Http2FlowControlQueueMaximumTooLow")] + [LoggerMessage(66, LogLevel.Debug, @"Connection id ""{ConnectionId}"" configured maximum flow control queue size {Actual} is less than the maximum streams per connection {Expected}. Increasing configured value to {Expected}.", EventName = "Http2FlowControlQueueMaximumTooLow")] public static partial void Http2FlowControlQueueMaximumTooLow(ILogger logger, string connectionId, int expected, int actual); } }