From 9db2626edcbc48b4319d758a0c90742473f10244 Mon Sep 17 00:00:00 2001 From: Mark Adamson <3154635+mungojam@users.noreply.github.com> Date: Thu, 1 May 2025 17:51:49 +0100 Subject: [PATCH 1/3] Add dotnet9 aot to benchmarks --- .../dotnet9_aot_on_provided_al2023/Dockerfile | 15 ++++++++++ .../dotnet9_aot_on_provided_al2023/build.sh | 20 +++++++++++++ .../src/Function.cs | 28 +++++++++++++++++++ .../src/LambdaPerf.csproj | 24 ++++++++++++++++ .../src/aws-lambda-tools-defaults.json | 9 ++++++ 5 files changed, 96 insertions(+) create mode 100644 s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/Dockerfile create mode 100644 s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh create mode 100644 s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/Function.cs create mode 100644 s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/LambdaPerf.csproj create mode 100644 s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json diff --git a/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/Dockerfile b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/Dockerfile new file mode 100644 index 0000000000..4fe80e0a53 --- /dev/null +++ b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/Dockerfile @@ -0,0 +1,15 @@ +ARG IMAGE_TAG +FROM $IMAGE_TAG/amazonlinux:2023 AS builder +ARG ARCH +WORKDIR /tmp +COPY src . +RUN yum update -y && yum install -y clang zlib-devel krb5-devel openssl-devel zip gzip tar wget +RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && ./dotnet-install.sh --version latest +ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 +ENV SSL_CERT_FILE=/tmp/noop +RUN /root/.dotnet/dotnet publish --configuration Release --arch $ARCH --output /tmp/publish +RUN zip -j /tmp/code.zip /tmp/publish/bootstrap + +FROM scratch +COPY --from=builder /tmp/code.zip / +ENTRYPOINT ["/code.zip"] diff --git a/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh new file mode 100644 index 0000000000..5be8541d7c --- /dev/null +++ b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh @@ -0,0 +1,20 @@ +DIR_NAME="./runtimes/$1" + +if [ $2 = "x86_64" ]; then + ARCH="x64" + IMAGE_TAG="amd64" + PLATFORM="linux/amd64" +elif [ $2 = "arm64" ]; then + ARCH="arm64" + IMAGE_TAG="arm64v8" + PLATFORM="linux/arm64" +else + echo "The process architecture $2 is set incorrectly. The value can only be either x86_64 or arm64." + exit 1 +fi + +rm ${DIR_NAME}/code_${2}.zip 2> /dev/null + +docker build --platform ${PLATFORM} ${DIR_NAME} --build-arg ARCH=${ARCH} --build-arg IMAGE_TAG=${IMAGE_TAG} -t maxday/dotnet9_on_provided_al2023_${2} +dockerId=$(docker create maxday/dotnet9_on_provided_al2023_${2}) +docker cp $dockerId:/code.zip ${DIR_NAME}/code_${2}.zip diff --git a/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/Function.cs b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/Function.cs new file mode 100644 index 0000000000..b2f36dd24d --- /dev/null +++ b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/Function.cs @@ -0,0 +1,28 @@ +using Amazon.Lambda.RuntimeSupport; +using Amazon.Lambda.Serialization.SystemTextJson; +using System.Text.Json.Serialization; + +namespace LambdaPerf; + +public class Function +{ + private static async Task Main() + { + await LambdaBootstrapBuilder.Create(FunctionHandler, new SourceGeneratorLambdaJsonSerializer()) + .Build() + .RunAsync(); + } + + public static StatusResponse FunctionHandler() + { + return new StatusResponse(StatusCode: 200); + } +} + +public record StatusResponse(int StatusCode); + +[JsonSerializable(typeof(StatusResponse))] +[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] +public partial class LambdaFunctionJsonSerializerContext : JsonSerializerContext +{ +} diff --git a/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/LambdaPerf.csproj b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/LambdaPerf.csproj new file mode 100644 index 0000000000..269f76e49c --- /dev/null +++ b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/LambdaPerf.csproj @@ -0,0 +1,24 @@ + + + + Lambda + Exe + bootstrap + net9.0 + enable + enable + true + true + false + true + Speed + true + + + + + + + + + diff --git a/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json new file mode 100644 index 0000000000..715c63a28a --- /dev/null +++ b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src/aws-lambda-tools-defaults.json @@ -0,0 +1,9 @@ +{ + "configuration": "Release", + "environment-variables" : "SSL_CERT_FILE=/tmp/noop", + "framework": "net9.0", + "function-runtime": "provided.al2023", + "function-memory-size": 256, + "function-timeout": 30, + "function-handler": "bootstrap" +} From f6ac0c8b57c0ba3b89af96e71385acec9ac3c76d Mon Sep 17 00:00:00 2001 From: Mark Adamson <3154635+mungojam@users.noreply.github.com> Date: Sun, 4 May 2025 22:01:30 +0100 Subject: [PATCH 2/3] add dotnet 9 to dependabot and readme --- .github/dependabot.yml | 4 ++++ README.md | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0a09971f80..f82fa4f0fa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -51,6 +51,10 @@ updates: directory: "s3-uploader/runtimes/dotnet8_aot_on_provided_al2023/src" schedule: interval: "daily" + - package-ecosystem: "nuget" + directory: "s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/src" + schedule: + interval: "daily" - package-ecosystem: "gomod" directory: "s3-uploader/runtimes/go_on_provided_al2" schedule: diff --git a/README.md b/README.md index 2dc9afa8e1..3e71a4a744 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ An ultra simple hello-world function has been written in each AWS supported runt - `python3.12` - `python3.13` - `dotnet6` +- `dotnet8` - `java11` - `java11 + snapstart` - `java17` @@ -50,6 +51,7 @@ in addition to the following custom runtimes: - `dotnet7 aot` on `provided.al2` - `dotnet8 aot` on `provided.al2` - `dotnet8 aot` on `provided.al2023` +- `dotnet9 aot` on `provided.al2023` - `quarkus native` on `provided.al2` - `graalvm java17` on `provided.al2` - `graalvm java21` on `provided.al2023` From ddd11e0fd626b2d17db22cb392b1c70173922d42 Mon Sep 17 00:00:00 2001 From: Mark Adamson Date: Sun, 4 May 2025 22:15:01 +0100 Subject: [PATCH 3/3] fix permissions on build.sh --- s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh diff --git a/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh b/s3-uploader/runtimes/dotnet9_aot_on_provided_al2023/build.sh old mode 100644 new mode 100755