Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit 4f4850a

Browse files
committed
New setting EnableKernelResponseBuffering to improve response write throughput
1 parent a8e4f69 commit 4f4850a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStream.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ internal RequestContext RequestContext
4242

4343
internal bool ThrowWriteExceptions => RequestContext.Server.Settings.ThrowWriteExceptions;
4444

45+
internal bool EnableKernelResponseBuffering => RequestContext.Server.Settings.EnableKernelResponseBuffering;
46+
4547
internal bool IsDisposed => _disposed;
4648

4749
public override bool CanSeek
@@ -431,6 +433,10 @@ private HttpApi.HTTP_FLAGS ComputeLeftToWrite(long writeCount, bool endOfRequest
431433
else if (!endOfRequest && _leftToWrite != writeCount)
432434
{
433435
flags |= HttpApi.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_MORE_DATA;
436+
if (EnableKernelResponseBuffering)
437+
{
438+
flags |= HttpApi.HTTP_FLAGS.HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA;
439+
}
434440
}
435441

436442
// Update _leftToWrite now so we can queue up additional async writes.

src/Microsoft.Net.Http.Server/WebListenerSettings.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ public ILogger Logger
6161
/// </summary>
6262
public bool ThrowWriteExceptions { get; set; }
6363

64+
/// <summary>
65+
/// Gets or sets a value that indicates whether to enable buffering of data in the kernel on a per-response basis.
66+
/// It should be used by an application doing synchronous I/O or by an application doing asynchronous I/O with
67+
/// no more than one outstanding send at a time.
68+
/// Applications that use asynchronous I/O and that may have more than one send outstanding at a time should not use this flag.
69+
/// Enabling this can results in higher CPU and memory usage by Http.Sys.
70+
/// </summary>
71+
public bool EnableKernelResponseBuffering { get; set; }
72+
6473
/// <summary>
6574
/// Gets or sets the maximum number of requests that will be queued up in Http.Sys.
6675
/// </summary>

0 commit comments

Comments
 (0)