C
C#8mo ago
Joo

Hello World taking 30 seconds + to run

Honestly baffled as to how this is possible. I'm running an ubuntu docker container locally on my m1 mac. I am installing dotnet in my dockerfile with the dotnet-install script like so:
RUN wget https://dot.net/v1/dotnet-install.sh \
&& chmod +x ./dotnet-install.sh \
&& ./dotnet-install.sh --channel 6.0 --install-dir /home/.dotnet \
&& chmod -R og=rwx /home/.dotnet \
&& export PATH="/home/.dotnet:$PATH" \
&& dotnet new console -o /home/project \
&& chmod -R og=rwx /home/project \
RUN wget https://dot.net/v1/dotnet-install.sh \
&& chmod +x ./dotnet-install.sh \
&& ./dotnet-install.sh --channel 6.0 --install-dir /home/.dotnet \
&& chmod -R og=rwx /home/.dotnet \
&& export PATH="/home/.dotnet:$PATH" \
&& dotnet new console -o /home/project \
&& chmod -R og=rwx /home/project \
When I go to run hello world, I copy the hello world c# file into the project and run it like so:
cp main.cs project/Program.cs \
&& dotnet run --project project
cp main.cs project/Program.cs \
&& dotnet run --project project
It may be worth noting that because I'm using jupyterhub to spin up docker containers on demand, the first time I try to run the hello world I get a whole "welcome to C#" spiel and it takes over a minute. However, on all subsequent runs (with the docker container ready) it doesn't do that but it still takes usually around 30-40 seconds at least. Am I missing something? How on earth could it be this slow?
29 Replies
x0rld
x0rld8mo ago
dotnet run doesn't just execute your program
Joo
Joo8mo ago
is there a better way to just execute it? i saw script but that seems to be for single files only
x0rld
x0rld8mo ago
./MyProgram 🤔
Joo
Joo8mo ago
that's only if it's already built, no? i need to build it on demand each time
x0rld
x0rld8mo ago
what are you trying to do exactly ?
Joo
Joo8mo ago
and besides, when googling for stuff like this i saw people complaining about slow load speeds - and they were talking like 3 seconds (for run) specifically. this seems like something is really messed up to be exact on what im trying to do: an ide that runs c# programs in the browser using websockets to communicate with the docker container running on server that can run the code on demand the infrastructure is there for other languages so its just a question of getting the c# to be performant im not sure if its a local thing due to some weird interaction with m1 chips or something because it was hard enough even getting c# to install without segfaulting thats why i had to use version 6.0
x0rld
x0rld8mo ago
getting c# without segfault ? O_o
Joo
Joo8mo ago
.net*
x0rld
x0rld8mo ago
what ever wtf ?
Joo
Joo8mo ago
the .net install script segfaults when trying to install
x0rld
x0rld8mo ago
btw just use a dotnet sdk image
Joo
Joo8mo ago
its a known issue
Joo
Joo8mo ago
GitHub
Segmentation fault building project on dotnet/sdk:7.0 image with Ap...
Describe the Bug Running into a problem where creating a docker image from mcr.microsoft.com/dotnet/sdk:7.0 on an M1 Apple MacBook Pro throws a segmentation fault from package qemu during publish. ...
x0rld
x0rld8mo ago
it's not installing .NET
Joo
Joo8mo ago
right yeah mb not the install script the setup of the project afterwards
x0rld
x0rld8mo ago
they say publish 🤔 you don't have to publish anything
Joo
Joo8mo ago
i mean i didnt publish anything and it still segfaulted lol im not making this up? clearly theres an issue with dotnet and m1s regardless of whether my issue is EXACTLY the same as theirs
x0rld
x0rld8mo ago
at the end they say that it's a QEMU error and give this link to read more on how to use without QEMU https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/
Joo
Joo8mo ago
well like i said i avoided the segfault by setting the version back - unless you think this might also be causing the slow performance?
x0rld
x0rld8mo ago
docker is running through as linux VM I don't think that's the best way to have performance aie has no native support for docker (cause it's an Unix OS )
Joo
Joo8mo ago
i wonder if i just need to test it on our actual live servers because it seems like it might just be an environment issue
x0rld
x0rld8mo ago
install dotnet on your mac and test it ? 🤔
Joo
Joo8mo ago
well then id lose the whole point of the test which is making sure it works on our docker containers which run the servers
x0rld
x0rld8mo ago
install virtualbox and setup everything in a whatever distrib you will use ?
Mayor McCheese
Mayor McCheese8mo ago
Is this to run adhoc code from a website?
MODiX
MODiX8mo ago
Mayor McCheese
REPL Result: Success
Console.WriteLine("Hello World");
Console.WriteLine("Hello World");
Console Output
Hello World
Hello World
Compile: 503.617ms | Execution: 72.247ms | React with ❌ to remove this embed.
Mayor McCheese
Mayor McCheese8mo ago
Iirc we're doing that with this bot @Cisien I think you wrote the eval code doesn't it run in a container?
Cisien
Cisien8mo ago
yes
Cisien
Cisien8mo ago
GitHub
GitHub - discord-csharp/CSharpRepl: CSharpRepl is a web api for C# ...
CSharpRepl is a web api for C# REPL using the Roslyn Scripting APIs - GitHub - discord-csharp/CSharpRepl: CSharpRepl is a web api for C# REPL using the Roslyn Scripting APIs