Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update csharp infra #397

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dotnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
sudo apt-add-repository https://packages.microsoft.com/ubuntu/22.04/prod
sudo apt-get update
sudo apt-get install -y libmsquic zlib1g-dev
sudo apt-get install -y libmsquic zlib1g-dev clang
Copy link
Contributor Author

Choose a reason for hiding this comment

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

haven't validated this is sufficient to get nativeaot to build in the container. if necessary we can remove it from bench.yml for now as the other changes should be fine.

2 changes: 2 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
codon,
cpp,
csharp,
csharp_preview,
csharp_native_aot,
crystal,
d,
dart,
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,18 @@ _Current benchmarks problems and their implementations are from [The Computer La

[podman](https://podman.io/getting-started/installation) (or [docker](https://www.docker.com/) by changing `docker_cmd: podman` to `docker_cmd: docker` in `bench/bench.yaml`)

unzip

## Build

_The 1st step is to build source code from various of lanuages_

```bash
cd bench
# To build a subset
dotnet run -p tool -- --task build --langs lisp go --problems nbody helloworld --force-rebuild
dotnet run --project tool -- --task build --langs lisp go --problems nbody helloworld --force-rebuild
# To build all
dotnet run -p tool -- --task build
dotnet run --project tool -- --task build
```

## Test
Expand All @@ -84,9 +86,9 @@ _The 2nd step is to test built binaries to ensure the correctness of their imple
```bash
cd bench
# To test a subset
dotnet run -p tool -- --task test --langs lisp go --problems nbody helloworld
dotnet run --project tool -- --task test --langs lisp go --problems nbody helloworld
# To test all
dotnet run -p tool -- --task test
dotnet run --project tool -- --task test
```

## Bench
Expand All @@ -96,16 +98,16 @@ _The 3rd step is to generate benchmarks_
```bash
cd bench
# To bench a subset
dotnet run -p tool -- --task bench --langs lisp go --problems nbody helloworld
dotnet run --project tool -- --task bench --langs lisp go --problems nbody helloworld
# To bench all
dotnet run -p tool -- --task bench
dotnet run --project tool -- --task bench
```

_For usage_

```bash
cd bench
dotnet run -p tool -- -h
dotnet run --project tool -- -h

BenchTool
Main function
Expand Down
2 changes: 2 additions & 0 deletions bench/bench_csharp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ problems:
- name: regex-redux
source:
- 5.cs
- 5-m.cs
- 6.cs
- 6-m.cs
- name: mandelbrot
source:
- 1.cs
Expand Down
4 changes: 3 additions & 1 deletion bench/bench_csharp_native_aot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lang: csharp
lang: csharp_native_aot
problems:
- name: helloworld
source:
Expand Down Expand Up @@ -34,7 +34,9 @@ problems:
- name: regex-redux
source:
- 5.cs
- 5-m.cs
- 6.cs
- 6-m.cs
- name: mandelbrot
source:
- 1.cs
Expand Down
124 changes: 64 additions & 60 deletions bench/bench_csharp_preview.yaml
Original file line number Diff line number Diff line change
@@ -1,68 +1,72 @@
lang: csharp
enabled: false
lang: csharp_preview
problems:
# - name: helloworld
# source:
# - 1.cs
# - name: binarytrees
# source:
# - 1.cs
# - name: merkletrees
# source:
# - 1.cs
# - 2.cs
# - name: nbody
# source:
# - 8.cs
# - 9.cs
# - name: spectral-norm
# source:
# - 3.cs
# - name: pidigits
# source:
# - 1.cs
# - name: edigits
# source:
# - 1.cs
# - name: fannkuch-redux
# source:
# # - 9.cs
# - name: fasta
# source:
# - 5.cs
# - name: knucleotide
# source:
# - 6.cs
- name: helloworld
source:
- 1.cs
- name: binarytrees
source:
- 1.cs
- name: merkletrees
source:
- 1.cs
- 2.cs
- name: nbody
source:
- 8.cs
- 9.cs
- name: spectral-norm
source:
- 3.cs
- name: pidigits
source:
- 1.cs
- name: edigits
source:
- 1.cs
- name: fannkuch-redux
source:
# - 9.cs
- name: fasta
source:
- 5.cs
- name: knucleotide
source:
- 6.cs
- name: regex-redux
source:
- 5.cs
# - 5p.cs
# - name: mandelbrot
# source:
# - 1.cs
# - 2.cs
# - 3.cs
# - name: json-serde
# source:
# - 1.cs
# - 2.cs
# - name: coro-prime-sieve
# source:
# - 1.cs
- 5-m.cs
- 6.cs
- 6-m.cs
- name: mandelbrot
source:
- 1.cs
- 2.cs
- 3.cs
- name: json-serde
source:
- 1.cs
- 2.cs
- name: coro-prime-sieve
source:
- 1.cs
- name: http-server
source:
- 1.cs
- 2.cs
- 2-http2.cs
- 2-http3.cs
# - name: nsieve
# source:
# - 1.cs
# - 2.cs
# - name: lru
# source:
# - 1.cs
# - 2.cs
# - name: secp256k1
# source:
# - 1.cs
- name: nsieve
source:
- 1.cs
- 2.cs
- name: lru
source:
- 1.cs
- 2.cs
- name: secp256k1
source:
- 1.cs
compiler_version_command:
compiler_version_regex:
runtime_version_parameter:
Expand All @@ -73,10 +77,10 @@ environments:
compiler: dotnet
version: 7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

possibly this should be 8 too, but I guess it works.

compiler_version_command: dotnet --version
docker: mcr.microsoft.com/dotnet/sdk:7.0
docker: mcr.microsoft.com/dotnet/sdk:8.0
# docker_volumns:
# - /tmp/.nuget/packages:/root/.nuget/packages
include: dotnet_preview
build: dotnet publish -c Release -r linux-x64 -f net7 --self-contained true -p:PublishSingleFile=true -o out # -p:PublishReadyToRun=true
build: dotnet publish -c Release -r linux-x64 -f net8 --self-contained true -p:PublishSingleFile=true -o out # -p:PublishReadyToRun=true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could target net7 just as well, but bench\include\dotnet_preview\app.csproj targets net8 so I had to change one or the other.

out_dir: out
run_cmd: app
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

internal static partial class Interop
{
internal static partial class procfs
internal static partial class ProcFs
{
internal const string RootPath = "/proc/";
private const string StatusFileName = "/status";
Expand Down
2 changes: 1 addition & 1 deletion bench/tool/Linux/procfs/Interop.ProcFsStat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

internal static partial class Interop
{
internal static partial class procfs
internal static partial class ProcFs
{
private const string ExeFileName = "/exe";
private const string CmdLineFileName = "/cmdline";
Expand Down
8 changes: 4 additions & 4 deletions bench/tool/ProcessUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ private static async Task<IReadOnlySet<int>> GetImmediateChildProcessIdsLinuxAsy
long totalMemoryBytes = 0;
if (s_isLinux)
{
if (procfs.TryReadStatFile(pid, out procfs.ParsedStat stat))
if (ProcFs.TryReadStatFile(pid, out ProcFs.ParsedStat stat))
{
m.CpuTimeUser = TicksToTimeSpanLinux(stat.utime + stat.cutime);
m.CpuTimeKernel = TicksToTimeSpanLinux(stat.stime + stat.cstime);
isChildProcessCpuTimeCounted = stat.cutime > 0 || stat.cstime > 0;
if (procfs.TryReadStatusFile(pid, out procfs.ParsedStatus status))
if (ProcFs.TryReadStatusFile(pid, out ProcFs.ParsedStatus status))
{
totalMemoryBytes = (long)status.VmRSS;
}
Expand Down Expand Up @@ -276,14 +276,14 @@ private static async Task<IReadOnlySet<int>> GetImmediateChildProcessIdsLinuxAsy
m.CpuTimeKernel += cp.PrivilegedProcessorTime;
totalMemoryBytes += cp.WorkingSet64;
}
else if (procfs.TryReadStatFile(cp.Id, out procfs.ParsedStat cpstat))
else if (ProcFs.TryReadStatFile(cp.Id, out ProcFs.ParsedStat cpstat))
{
if (!isChildProcessCpuTimeCounted)
{
m.CpuTimeUser += TicksToTimeSpanLinux(cpstat.utime);
m.CpuTimeKernel += TicksToTimeSpanLinux(cpstat.stime);
}
if (procfs.TryReadStatusFile(cp.Id, out procfs.ParsedStatus cpstatus))
if (ProcFs.TryReadStatusFile(cp.Id, out ProcFs.ParsedStatus cpstatus))
{
totalMemoryBytes += (long)cpstatus.VmRSS;
}
Expand Down