Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/web/ConsoleLineArgumentsParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ public enum SocketEngineType
EPoll,
IOUring,
IOUringTransport,
LinuxTransport
LinuxTransport,
DefaultTransport
}

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")]
Expand Down
64 changes: 36 additions & 28 deletions test/web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,45 @@ public static IHostBuilder CreateHostBuilder(string[] args, CommandLineOptions c
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonfirsov fyi, we've added an option for DontAllocateMemoryForIdleConnections in dotnet/aspnetcore#19396.

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;
}
});
}
Expand All @@ -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,
Expand Down