-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
I'm testing .NET 10 vs .NET 8 in AWS Lambda to get ready for adding .NET 10 as a managed runtime in AWS Lambda. I know I should have done the performance testing months ago but always something getting in the way.
Breaking down the AWS Lambda environment into a more basic explanation I'm testing both .NET 8 and .NET 10 as self contained applications with no trimming enabled and R2R enabled. In Lambda you are working with a small slice of CPU power in the compute environment. The Lambda function itself is nothing more then a hello world. The .NET Lambda runtime client is started up and is largely a glorified HttpClient making calls to make calls communicating the status of processing an event. The HTTP calls are local going over IP addresses and not using HTTPS.
I'm seeing .NET 10 having a 5 to 10 percent regression in the first invoke where the .NET runtime has to be started.
In Lambda I can't attach a profiler but I added the following event listener to capture the .NET runtime events.
public class ConsoleListener : EventListener
{
protected override void OnEventSourceCreated(EventSource eventSource)
{
// Attach to interesting sources
if (eventSource.Name == "Microsoft-Windows-DotNETRuntime")
{
EnableEvents(eventSource, EventLevel.Informational,
(EventKeywords)(-1)); // All keywords
}
}
protected override void OnEventWritten(EventWrittenEventArgs e)
{
string value = string.Empty;
if (e.Payload != null)
{
value = string.Join(", ", e.Payload);
}
Console.WriteLine($"{e.EventName}: {value}");
}
}
Below are the links for the output of the cold start for both .NET 8 and 10 containing the .NET events.
.NET 8: https://github.com/normj/DotnetStartupPerformanceTest/blob/main/LambdaCaptures/dotnet8-metrics.txt
.NET 10: https://github.com/normj/DotnetStartupPerformanceTest/blob/main/LambdaCaptures/dotnet10-metrics.txt
I know data for this report is light. I'm working on collecting more information but given how close we are to .NET 10 release I didn't want to wait any longer to start a conversation. I'm kicking myself for not finding time to do this sooner. Maybe somebody on the .NET Team can see something important in the metrics files. From my analysis I see more .NET type being loaded, does this mean .NET 10 just does more at startup then .NET 8.
Regression?
This is a regression in cold start for .NET 8
Local Reproduction
In the README of my sample repository I have reproduction using containers which are built with the Lambda function and Lambda's Emulator. The instructions in the README give details on how to run it. Caveat I built the repo on a Windows Laptop and it is hard coded in the Dockerfile for X64 architecture.
https://github.com/normj/DotnetStartupPerformanceTest?tab=readme-ov-file#simulate-locally-with-lambda-emulator
Data
I have collected the metrics captures in the following repo
https://github.com/normj/DotnetStartupPerformanceTest/tree/main
I also added a console application that I explain in the README that I see some similar behavior when I run inside a container when using the --cpus=0.1 switch to simulate the slice of CPU Lambda would give. Without the switch .NET 10 is faster but with the switch .NET 8 is faster although the difference is not as much as I'm seeing in Lambda. The README in the repo gives the instructions on how I run it.