Skip to content

Commit

Permalink
Update dotnet example (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
brancz authored Nov 8, 2024
1 parent a1a13a9 commit 09a206f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
5 changes: 2 additions & 3 deletions dotnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
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"
Expand All @@ -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"]
6 changes: 3 additions & 3 deletions dotnet/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -22,7 +22,7 @@ static void Main(string[] args)
{
while (true)
{
Console.WriteLine(Fibonacci(42));
Console.WriteLine(Fibonacci(1000000000));
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion dotnet/README.md
Original file line number Diff line number Diff line change
@@ -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
20 changes: 10 additions & 10 deletions dotnet/demo.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
6 changes: 3 additions & 3 deletions dotnet/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 09a206f

Please sign in to comment.