Skip to content

Commit

Permalink
Clarify some log messages and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amcasey authored and vseanreesermsft committed Sep 27, 2023
1 parent c1d9659 commit 90be960
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/Servers/Kestrel/Core/src/Internal/Http2/Http2Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 90be960

Please sign in to comment.