From 1604f01d55d0584253db16baadf2e19d67f9fb1a Mon Sep 17 00:00:00 2001 From: Frederic Branczyk Date: Fri, 8 Nov 2024 15:17:34 +0100 Subject: [PATCH] Update dotnet example --- dotnet/Dockerfile | 5 ++--- dotnet/Program.cs | 6 +++--- dotnet/README.md | 6 +++++- dotnet/demo.csproj | 20 ++++++++++---------- dotnet/deployment.yaml | 6 +++--- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/dotnet/Dockerfile b/dotnet/Dockerfile index 45d1551..a29d723 100644 --- a/dotnet/Dockerfile +++ b/dotnet/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base +FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base WORKDIR /app # Creates a non-root user with an explicit UID and adds permission to access the /app folder @@ -6,7 +6,7 @@ WORKDIR /app RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app USER appuser -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src COPY ["demo.csproj", "./"] RUN dotnet restore "demo.csproj" @@ -18,7 +18,6 @@ FROM build AS publish RUN dotnet publish "demo.csproj" -c Release -o /app/publish FROM base AS final -ENV DOTNET_PerfMapEnabled=1 WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "demo.dll"] diff --git a/dotnet/Program.cs b/dotnet/Program.cs index 9141bb0..48825a7 100644 --- a/dotnet/Program.cs +++ b/dotnet/Program.cs @@ -4,9 +4,9 @@ namespace Demo { class Program { - static int Fibonacci(int n) + static long Fibonacci(int n) { - int a = 0, b = 1, tmp; + long a = 0, b = 1, tmp; for (int i = 0; i < n; i++) { @@ -22,7 +22,7 @@ static void Main(string[] args) { while (true) { - Console.WriteLine(Fibonacci(42)); + Console.WriteLine(Fibonacci(1000000000)); } } } diff --git a/dotnet/README.md b/dotnet/README.md index b68c3af..94a3be3 100644 --- a/dotnet/README.md +++ b/dotnet/README.md @@ -1,3 +1,7 @@ # .NET -See https://learn.microsoft.com/en-us/dotnet/core/runtime-config/debugging-profiling#export-perf-maps +Version 7 and greater are supported. Version 8 introduced some things that make tracking functions a bit more difficult, but should largely still work. + +Known issues: +- Very large functions can fail to be symbolized. This will be fixed with: https://github.com/dotnet/runtime/pull/108939 +- The runtime can incorrectly track inlining and line numbers. This is an issue with exception backtraces as well. https://dotnetdocs.ir/Post/47/wrong-exception-line-number-in-stack-trace-in-release-mode diff --git a/dotnet/demo.csproj b/dotnet/demo.csproj index d439800..91b464a 100644 --- a/dotnet/demo.csproj +++ b/dotnet/demo.csproj @@ -1,10 +1,10 @@ - - - - Exe - net7.0 - enable - enable - - - + + + + Exe + net8.0 + enable + enable + + + diff --git a/dotnet/deployment.yaml b/dotnet/deployment.yaml index 7c43ccd..8bcc9bb 100644 --- a/dotnet/deployment.yaml +++ b/dotnet/deployment.yaml @@ -4,9 +4,8 @@ metadata: labels: app.kubernetes.io/name: demo-dotnet name: dotnet - namespace: parca spec: - replicas: 3 + replicas: 1 selector: matchLabels: app.kubernetes.io/name: demo-dotnet @@ -16,7 +15,8 @@ spec: app.kubernetes.io/name: demo-dotnet spec: containers: - - image: parca-demo:dotnet + - image: quay.io/brancz/parca-demo-dotnet:latest + imagePullPolicy: Always name: dotnet resources: limits: