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:
parent
80b9673693
commit
ba549502e1
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -112,5 +112,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
||||||
}
|
}
|
||||||
}, tcs);
|
}, tcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Schedule(Action action)
|
||||||
|
{
|
||||||
|
Run(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -34,5 +34,10 @@ namespace Microsoft.AspNetCore.Server.KestrelTests.TestHelpers
|
||||||
{
|
{
|
||||||
action(state);
|
action(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Schedule(Action action)
|
||||||
|
{
|
||||||
|
action();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue