[Mono-list] Mono VM speed

pinggi at centrum.cz pinggi at centrum.cz
Fri Apr 20 00:25:10 UTC 2012


Sorry, second try with little bit better formatting:

Elmar Haneke:
>You should use an profiler to investigate where the difference arises.
I don't have experiencies with that. Is there any good tools for that?

> At least you should make sure that both runs are using the same Gtk/Cairo and Gtk# libraries.
I looked again at modules list. Here it is:


* Run in Monodevelop in debug mode with Default fw selected (.Net fw 4.0):

Loaded Module 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
Started Thread 2280
Loaded Module 'E:\Dev\Projects\Linux\Cairo\PerfDrawing3\PerfDrawing3\bin\Debug\PerfDrawing3.exe'
Loaded Module 'C:\Windows\assembly\GAC\gtk-sharp\2.12.0.0__35e10195dab3c99f\gtk-sharp.dll'
Loaded Module 'C:\Windows\assembly\GAC\glib-sharp\2.12.0.0__35e10195dab3c99f\glib-sharp.dll'
Loaded Module 'C:\Windows\assembly\GAC\atk-sharp\2.12.0.0__35e10195dab3c99f\atk-sharp.dll'
Loaded Module 'C:\Windows\assembly\GAC\gdk-sharp\2.12.0.0__35e10195dab3c99f\gdk-sharp.dll'
Loaded Module 'C:\Windows\assembly\GAC_MSIL\Mono.Posix\2.0.0.0__0738eb9f132ed756\Mono.Posix.dll'
Loaded Module 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'
Started Thread 3848
Loaded Module 'C:\Windows\assembly\GAC_MSIL\Mono.Cairo\2.0.0.0__0738eb9f132ed756\Mono.Cairo.dll'


* Run in Monodevelop in debug mode with Monodevelop fw selected (Mono 2.10.8):

Loaded assembly: E:\Dev\Projects\Linux\Cairo\PerfDrawing3\PerfDrawing3\bin\Debug\PerfDrawing3.exe
Loaded assembly: C:\Program Files (x86)\Mono-2.10.8\lib\mono\gac\gtk-sharp\2.12.0.0__35e10195dab3c99f\gtk-sharp.dll [External]
Loaded assembly: C:\Program Files (x86)\Mono-2.10.8\lib\mono\gac\glib-sharp\2.12.0.0__35e10195dab3c99f\glib-sharp.dll [External]
Loaded assembly: C:\Program Files (x86)\Mono-2.10.8\lib\mono\gac\atk-sharp\2.12.0.0__35e10195dab3c99f\atk-sharp.dll [External]
Loaded assembly: C:\Program Files (x86)\Mono-2.10.8\lib\mono\gac\System\4.0.0.0__b77a5c561934e089\System.dll [External]
Loaded assembly: C:\Program Files (x86)\Mono-2.10.8\lib\mono\gac\Mono.Cairo\4.0.0.0__0738eb9f132ed756\Mono.Cairo.dll [External]
Loaded assembly: C:\Program Files (x86)\Mono-2.10.8\lib\mono\gac\gdk-sharp\2.12.0.0__35e10195dab3c99f\gdk-sharp.dll [External]
Loaded assembly: C:\Program Files (x86)\Mono-2.10.8\lib\mono\gac\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll [External]
There is difference in both Cairo libs.
Here are the libs from .Net fw gac:
>gacutil /l Mono.Cairo

Microsoft (R) .NET Global Assembly Cache Utility.  Version 3.5.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756,processorArchitecture=MSIL
  Mono.Cairo, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756

Number of items = 2
And here are the libs from Mono gac:

>C:\Program Files (x86)\Mono-2.10.8\bin>gacutil /l Mono.Cairo
The following assemblies are installed into the GAC:
Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
Mono.Cairo, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
Number of items = 2

As I know, it uses Mono.Cairo 2.0 when it is run on .Net Fw platform and Mono.Cairo 4.0 on Mono platform.


It is also strange that .Net fw 4.0 loads assembly from .Net fw 2.0 gac.
My referencies in the project file are the following:

  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
    <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
    <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
    <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
    <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
    <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
    <Reference Include="Mono.Posix" />
    <Reference Include="Mono.Cairo" />
  </ItemGroup>

I tried removing Mono.Cairo dll from referencies and adding it again from 'C:\Windows\assembly\GAC_MSIL\Mono.Cairo\2.0.0.0__0738eb9f132ed756\Mono.Cairo.dll', but I got 1 error in compilation process:
     
public void Update()
{
  lock (this)
  {
    using (Cairo.Context context = Gdk.CairoHelper.Create(GdkWindow)) { <-- Cannot implicitly convert type 'Cairo.Context' to 'Cairo.Context'
      RenderScene(context, Allocation.Width, Allocation.Height);
      ((IDisposable)context.Target).Dispose();
    }
  }
 }

I should also say that I try running it on Core duo laptop and mono and .net ran in the same speed (100 ms both @ Win7).


-----------------------------------------------
Justin Holewinski:

> Is your code doing a lot with floating-point values?

Every point (10 000) has double x,y coordinates. Lines are composed from 2 points and there is also some math for rotating with sin, cos functions.

> If so, it could be a floating-point precision issue.  I've found that the Mono JIT emits double-precision instructions (addsd, mulsd, etc.) for single-precision types, while the Microsoft compiler uses the single-precision versions (addss, mulss, etc.).  This can easily cause such a slowdown.
Can it be somehow influenced e.g. by command line parameter or it is "hardcoded"?



-----------------------------------------------
Rodrigo Kumpera:

> Is your benchmark of mono on windows?

yes, Win7

>Did you profile your app to see what the bottlenecks are?
I'd like to, but how can I do that actually in monodevelop?

> LLVM is not supported on windows and it's not enabled by default due to the significant overhead it imposes that makes it impractical for interactive applications. On 2.10, SGen is not enabled by default and it is not supported on windows.
It is really sad, that almost no optimalization is not supported on Win platform :-(


More information about the Mono-list mailing list