Use the IThreadPool as the ReaderScheduler (#1372)

- This is what socket input did, also using
ThreadPool.QueueUserWorkItem is better than Task.Run for this
scenario and avoids a bunch of overhead.
This commit is contained in:
David Fowler 2017-02-21 21:09:23 -08:00 committed by GitHub
parent 80b9673693
commit ba549502e1
4 changed files with 13 additions and 2 deletions

View File

@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
public PipeOptions LibuvPipeOptions => new PipeOptions public PipeOptions LibuvPipeOptions => new PipeOptions
{ {
ReaderScheduler = TaskRunScheduler.Default, ReaderScheduler = ServiceContext.ThreadPool,
WriterScheduler = Thread, WriterScheduler = Thread,
MaximumSizeHigh = ServiceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0, MaximumSizeHigh = ServiceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0,
MaximumSizeLow = ServiceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0 MaximumSizeLow = ServiceContext.ServerOptions.Limits.MaxRequestBufferSize ?? 0

View File

@ -2,12 +2,13 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.IO.Pipelines;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
{ {
public interface IThreadPool public interface IThreadPool : IScheduler
{ {
void Complete(TaskCompletionSource<object> tcs); void Complete(TaskCompletionSource<object> tcs);
void Cancel(TaskCompletionSource<object> tcs); void Cancel(TaskCompletionSource<object> tcs);

View File

@ -112,5 +112,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
} }
}, tcs); }, tcs);
} }
public void Schedule(Action action)
{
Run(action);
}
} }
} }

View File

@ -34,5 +34,10 @@ namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
{ {
action(state); action(state);
} }
public void Schedule(Action action)
{
action();
}
} }
} }