dotnet core slow on Raspberry Pi 2 - .net-core

Dotnet core runtime is slow to start on Raspberry Pi 2
Raspberry Pi 2 was set up using the Lite (Raspbian 10, Buster) tar file from Raspbian site.
I installed openssh, php7.1, dotnet runtime and mono. I already have a RabbitMQ server running on a separate linux box.
I am using the Getting Started Example #1 (hello-world) send code found on the RabbitMQ site, https://www.rabbitmq.com/getstarted.html
On my Raspberry Pi 2 I have installed the following
PHP 7.1 for testing the PHP Send code on the CLI
dotnet 2.2 core for testing the C# Send code (as Console App)
mono for testing the C# Send code as Framework 4.7.2 (as Console App)
Added to the example tutorial code I added the Stopwatch so I could measure elapsed time.
The Results are below
dotnet - Elapsed Time = 00:00:07.1991475
mono - Elapsed Time = 00:00:04.3602941
php - Elapsed Time = 00:00:00.1396138
I was under the impression that coding in Dotnet core would be faster than Framework (using mono).
So I thought it could be the RabbitMQ library (NuGet - RabbitMq.Client)
So decided to create two new projects with just the Hello World in the console.write.
The results were very similar.
dotnet - 7 sec
mono - 4 sec
php - 0 sec
I was hoping to write my application in C# but unless I can get the performance issue resolved it looks like PHP is the way to go for my project.
Is there anything I can try to improve the performance?
After a lot of searching I have found similar problems but the articles were old and referred to dotnet core 2.1 in early releases. I kinda hoped that by dotnet core 2.2 release the Arm CPU supported would have been better. Especially with the push on IoT.
The Arm CPU I'm running in my Raspberry Pi 2 is ARMv7 rev 5 (v71).
I tried a Raspberry Pi 1, 2 & 3 and sadly the same results.
Except on a Raspberry Pi 1 you can't install dotnet (not supported on ARMv6 CPU) so only mono and PHP were tested on that.
Any ideas....

To improve startup times there are a few things you can do according to the guidance and my experience.
If possible for your app migrate to dotnetcore3.0, which seems to have significant performance and startup benefits.
Enable TieredCompilation in your csproj. As described here https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#tiered-compilation
<PropertyGroup>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<TieredCompilation>true</TieredCompilation>
</PropertyGroup>
Use ReadyToRun images, by enabling this in your csproj. As described here https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#tiered-compilation
In csproj.
Consider also using the Trimming feature to reduce binary sizes when publishing a single-exe. This reduces the amount of data needed to be read from disk to execute your app.
This issue has been discussed also in context of Amazon Lambda, that cold start times are quite high.
So far it seems the best ways are reducing dll sizes, using ReadyToRun to reduce JIT times and TieredCompilation. These changes have worked for us remarkably, when combined with dotnetcore3.0.
There is some guidance provided by Scott Hanselman here https://www.hanselman.com/blog/MakingATinyNETCore30EntirelySelfcontainedSingleExecutable.aspx

Related

Disappointing First UNO Experience. Only WASM works

I've spent the weekend and have still failed to get a "Hello, World" working.
Visual Studio:
2022 Version 17.0.4
2022 Preview Version 17.1.0 Preview 1.1
uno-check says everything is fine:
Here are my runtimes:
Neither WUX or MUX (UWP or Desktop) flavors of WinUI work. Android emulators coming up but the Hello World not deploying. Local Android device detected, but not deploying. Linux (Skia.GTK) not working.
WASM IS able to display the text "Hello, World".
Wow! I was jazzed after watching every minute of the recent version 4 release conference. But if it is this difficult to just get the thing running ... ?
I'm determined to get it working ... but it appears to be a major unproductive project to do so. Am I the only one in the world having difficulty?
Mark
Ok, I was able to get WinUI (Desktop), WASM, Skia (WPF for Windows 7), Skia (GTK for Linux), and Android working with "Hello, World". Let me share what I learned and hopefully spare others this painful experience I've had.
Of course, before doing the following steps you'll want to install and run unocheck, so follow the documentation to do so and make sure all issues are resolved.
Once you pass unocheck, then:
First, forget about using .NET 6! They aren't ready.
This is what cost me most of my time. Uno 4 may advertise as .NET 6 compatible and they're getting close ... but they are not there yet.
Forget about using project templates within Visual Studio. Amazingly, even after releasing version 4.0 they haven't completed a template for the most important project that developers want: WinUI 3 Desktop. So, for now, just focus on using the CLI to install and invoke templates.
Open the cmd prompt and install templates with the following command:
dotnet new -i Uno.ProjectTemplates.Dotnet
This will install several templates. If you want to create a cross-platform application based on WinUI 3 Desktop (Win32) version, then:
First create the containing folder (like C:\Users\Mark\Code). Then, using the command prompt, navigate to this folder and from within this folder enter the following command:
dotnet new unoapp-winui -o SolutionName
This will produce a .NET 5 solution with a packaged WinUI 3 Desktop as the main development head. The WinUI 3 head will have a dependency on the latest WindowsAppSDK ver. 1.0 (formerly Project Reunion).
DO NOT USE THE COMMAND:
dotnet new unoapp-winui-net6 -o SolutionName
This will produce a .NET 6 solution that will be screwed up and won't work.
Hopefully, they'll have all this corrected in the coming weeks. I would just wait until NVentive releases updated Templates for Visual Studio that support WinUI 3 for .NET 6. Then it will be easy to upgrade your solution from .NET 5 to .NET 6.
When you run the dotnet new unoapp-winui -o SolutionName command, you will notice that several of the projects fail to "restore" properly:
To solve this, use the command prompt to navigate into each of the failed projects and enter the command:
dotnet restore
Now you're ready to use Visual Studio to launch your solution. Select the WinUI 3 Packaging Project as your startup project and attempt to run "Hello, World".
4. You may get this error:
Error MSB3270 There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference ..."
If so, open your build configuration and check whether your packaging and main WinUI 3 project use different CPU targets as shown here (BFRLE is the name of my solution):
I fixed this by changing the target platform of BFRLE.Windows.Desktop to x64 to match the packaging project. While you're in the configuration manager be sure that the Android project is deployed (otherwise it won't deploy during debugging).
Next, make sure that you install the GTK+3 runtime on your computer. you can do so here:
https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases
The absence of this runtime is NOT checked for in unocheck.
I also installed WSL.
At this point you ought to be able to run "Hello, World" as a local WinUI 3 Desktop app, as an IIS Express-hosted WASM app, as a Skia.WPF.Host app, and as a Skia.Gtk app. I didn't try to run the MacOS or iOS flavors since these require physical hardware. I did try to connect my old Android phone (Galaxy Note 5, OS 7 API 24). To get a phone recognized of course you have to enable Developer Mode and enable USB Debugging (see online docs). To get my phone recognized ... had to disable Fast Deployment. Even after this got my phone communicating, I was not able to successfully deploy to this old phone (I suspect I need to update my phone).
In order to use a virtual Android emulator you need to go to the project properties of the Android project and ENABLE Fast Deployment and Incremental Android Packaging as shown below:
You can accelerate your virtual Android emulator by enabling settings in Windows and your BIOS as explained here:
https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/android-emulator/hardware-acceleration?pivots=windows
The steps above finally got things working for me. It didn't matter whether I was using VS 2022 or VS 2022 preview -- so that's one less thing you have to worry about.
Now on to the more interesting problems of getting a real application to run cross-platform.

Why does WebAssembly fail to build on fresh Uno Platform template

Summary:
When I attempt to build and run my Uno WebAssembly on Ubuntu 20.04, it fails. The error cites a file or directory that doesn't exist.
Steps to reproduce:
Open Ubuntu 20.04 platform
Install .NET Core SDK 3.1.403
Follow the "Getting Started on VSCode" tutorial here
When you attempt to start the app with the .NET Core Launch configuration, note that the build fails.
Error Details:
/home/<user>/.nuget/packages/uno.wasm.bootstrap/1.3.4/build/Uno.Wasm.Bootstrap.targets(126,2): error : System.ComponentModel.Win32Exception (2): No such file or directory [/home/<user>/Projects/uapp/uapp.Wasm/uapp.Wasm.csproj]
What I've tried
My knowledge of Uno Platform is approximately 1 day old. I'm not sure I understand enough about it to even know what to try, but I have done these things:
Run dotnet run from within the uapp.Skia.Gtk, which successfully opened the window I expected to see.
Run dotnet run from within uapp.Wasm, which resulted in the error described above.
Look on the documentation for clues on why the file might not be found on a fresh template that's not been modified (I could not find anything)
Question:
What should I be doing differently to get the Web Assembly to build and display the app correctly?
EDIT: The file in the error does exist, precisely in the path in the error.
You're hitting an error that may happen when building with some native components, like SQLite or Skia.
To fix this, you'll need to execute the dotnet-setup.sh installation script which is not yet run automatically.
This script installs .NET Core, mono and ninja, on ubuntu-alike systems.

Building QT libraries on Ubuntu Linux

I am trying to build QT libraries 4.8.2 on Ubuntu Linux by following the instruction mentioned in the documentation .
This is the second time I am trying building... I tried earlier also and when build process did not complete even after 12-13 hrs I thought something is wrong so I started from beginning.
It's been almost 24 hrs I issued make command (In the second attempt) the build process is still going on. Terminal is not showing any error either.
Does building QT libraries on Ubuntu Linux really takes this much time or I have missed something.
Building Qt takes a couple of hours even on a fast system if you only do the default non-parallel build. By default it also pulls in lots of libraries that you may not need.
So the first thing to try is make -j to do parallel builds. If that is still taking too long then try to slim down the libraries Qt generates. Do you need QtWebKit for instance? If you plan on using an embedded web browser in your application then you'll want it. If not then you can halve the time of your build. Type configure --help to see the options. Some useful ones that can reduce the build time are:
NOTE: some of the following options are no longer applicable in Qt5
-fast - Use this if you are just using Qt rather than developing Qt itself
-no-webkit - If you don't need the embedded web browser this makes a huge difference
-release - If you don't need the debug libraries then this can be quicker
-no-qt3-support - you won't need this for a new project
-nomake examples - don't build the examples
-nomake demos - don't build the demos
-no-declarative - If you're not using the QtQuick APIs then omit this
-nomake docs - don't build the documentation (this can save a lot of time)
If you're having to pay for the time in this Amazon instance then another option is to create a local Ubuntu machine (on a spare machine or in a virtual machine) and tweak the options there until you get something that works, then use that build configuration on your Amazon instance.
EDIT:
In Qt5, the project changed to use git submodules, so if you are building from a git checkout then the default behaviour is to clone all the submodules, which will add substantially to your build times if there are modules you don't need. There is a script init-repository that is part of the qt5 repository. You can use that to trim your local repository to only contain the submodules you need. So for instance:
git clone https://git.gitorious.org/qt/qt5.git
cd qt5
./init-repository --module-subset="qtbase qtdeclarative qtquick1"
configure --your-options-here
make -j
On my machine I can do a basic build of qtbase in about 10 minutes
memory requirements to compile Qt 4.7 are 1.2 Gb (mostly demanded by QWebKit link stage), if you don't have enough create an extra swap file (see https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-swap-creating-file.html)

How to improve Qt + MSVC compile times on Windows 7?

The compile times on Windows 7 with Qt, using MSVC10 express and MS SDK 7.1 are longer than they were under Windows XP (still using MSVC10). What's more, when using MinGW my compile times are faster than either MSVC10 scenario.
The CPU seems to only spend 10% max and "Jom" is present.
Would anyone have an idea as to what might cause this? Is there anything I can do to speed up my compile times?
You mention that jom is present. Please set for the make-command the parameter "-j 8". Where 8 is just as example - not sure how many threads your machine can fed properly. Because your cpu-usage of ~10% indicates that just a single core is used.

Rails Warbler Deployment

I am doing some testing to determine resource usage of a rails war. I have used Warbler to package the "15-minute Blog" application using Rails 2.3.5 and JRuby 1.4.0. I am deploying into Tomcat 6.0.24 and create multiple deployments by copying the blog.war file as blogN.war.
This worked great for the first 4 deployments but I can't seem to deploy any more than 4 instances of the war; in other words, the catalina.out log hangs with "Deploying web application archive blog5.war".
Any ideas on what the problem might be or how I might better trouble-shoot this?
Increasing PermGenSpace memory to "-XX:PermSize=64m -XX:MaxPermSize=128m" corrected this problem.
Check your log files, may be the case that your java process, in which tomcat executes, runs out of memory, see java parameters ( -Xmx -Xms ) and http://wiki.apache.org/tomcat/FAQ/Memory . Increasing the available memory may allow you to run more instances of the application.

Resources