diff --git a/test/web/ConsoleLineArgumentsParser.cs b/test/web/ConsoleLineArgumentsParser.cs index bbb8af4..b2836e0 100644 --- a/test/web/ConsoleLineArgumentsParser.cs +++ b/test/web/ConsoleLineArgumentsParser.cs @@ -11,7 +11,8 @@ public enum SocketEngineType EPoll, IOUring, IOUringTransport, - LinuxTransport + LinuxTransport, + DefaultTransport } public class CommandLineOptions @@ -19,7 +20,7 @@ public class CommandLineOptions // the booleans MUST be nullable, otherwise --arg false does not work... // see https://github.com/commandlineparser/commandline/issues/290 for more details - [Option('e', "engine", Required = false, Default = SocketEngineType.IOUring, HelpText = "EPoll/IOUring/IOUringTransport/LinuxTransport")] + [Option('e', "engine", Required = false, Default = SocketEngineType.IOUring, HelpText = "EPoll/IOUring/IOUringTransport/LinuxTransport/DefaultTransport")] public SocketEngineType SocketEngine { get; set; } [Option('t', "thread-count", Required = false, Default = 1, HelpText = "Thread Count, default value is 1")] diff --git a/test/web/Program.cs b/test/web/Program.cs index b89aea7..f6bf580 100644 --- a/test/web/Program.cs +++ b/test/web/Program.cs @@ -34,38 +34,45 @@ public static IHostBuilder CreateHostBuilder(string[] args, CommandLineOptions c .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); - if (commandLineOptions.SocketEngine == SocketEngineType.IOUringTransport) + + switch (commandLineOptions.SocketEngine) { - webBuilder.ConfigureServices(serviceCollection => - serviceCollection.AddIoUringTransport(options => + case SocketEngineType.IOUringTransport: + webBuilder.ConfigureServices(serviceCollection => + serviceCollection.AddIoUringTransport(options => + { + options.ThreadCount = commandLineOptions.ThreadCount; + options.ApplicationSchedulingMode = commandLineOptions.ApplicationCodeIsNonBlocking.Value ? + PipeScheduler.Inline : PipeScheduler.ThreadPool; + })); + break; + case SocketEngineType.LinuxTransport: + webBuilder.UseLinuxTransport(options => { options.ThreadCount = commandLineOptions.ThreadCount; - options.ApplicationSchedulingMode = commandLineOptions.ApplicationCodeIsNonBlocking.Value ? - PipeScheduler.Inline : PipeScheduler.ThreadPool; - })); - } - else if (commandLineOptions.SocketEngine == SocketEngineType.LinuxTransport) - { - webBuilder.UseLinuxTransport(options => - { - options.ThreadCount = commandLineOptions.ThreadCount; - options.DeferSend = commandLineOptions.DeferSends.Value; - options.ApplicationSchedulingMode= commandLineOptions.ApplicationCodeIsNonBlocking.Value ? + options.DeferSend = commandLineOptions.DeferSends.Value; + options.ApplicationSchedulingMode= commandLineOptions.ApplicationCodeIsNonBlocking.Value ? PipeScheduler.Inline : PipeScheduler.ThreadPool; - }); - } - else - { - webBuilder.UseLinuxAsyncSockets(options => + }); + break; + case SocketEngineType.DefaultTransport: + webBuilder.UseSockets(options => { - options.DispatchContinuations = commandLineOptions.DispatchContinuations.Value; - options.DeferSends = commandLineOptions.DeferSends.Value; - options.DeferReceives = commandLineOptions.DeferReceives.Value; - options.DontAllocateMemoryForIdleConnections = commandLineOptions.DontAllocateMemoryForIdleConnections.Value; - options.OutputWriterScheduler = commandLineOptions.OutputWriterScheduler; - options.ApplicationCodeIsNonBlocking = commandLineOptions.ApplicationCodeIsNonBlocking.Value; - } - ); + options.IOQueueCount = commandLineOptions.ThreadCount; + }); + break; + default: + webBuilder.UseLinuxAsyncSockets(options => + { + options.DispatchContinuations = commandLineOptions.DispatchContinuations.Value; + options.DeferSends = commandLineOptions.DeferSends.Value; + options.DeferReceives = commandLineOptions.DeferReceives.Value; + options.DontAllocateMemoryForIdleConnections = commandLineOptions.DontAllocateMemoryForIdleConnections.Value; + options.OutputWriterScheduler = commandLineOptions.OutputWriterScheduler; + options.ApplicationCodeIsNonBlocking = commandLineOptions.ApplicationCodeIsNonBlocking.Value; + } + ); + break; } }); } @@ -84,7 +91,8 @@ private static AsyncEngine CreateAsyncEngine(CommandLineOptions commandLineOptio return new IOUringAsyncEngine(threadCount: commandLineOptions.ThreadCount, batchOnIOThread); case SocketEngineType.IOUringTransport: - case SocketEngineType.LinuxTransport: + case SocketEngineType.LinuxTransport: + case SocketEngineType.DefaultTransport: // Create EPollAsyncEngine with threadCount of zero. return new EPollAsyncEngine(threadCount: 0, useLinuxAio: false,