[Mono-dev] mono numerical performance

Jonathan Shore jonathan.shore at gmail.com
Sat Nov 19 20:13:42 EST 2011


I write scientific numerical algorithms that are very data / array intensive.  Having recently moved from using the JVM to the Mono CLR, was curious about the pure numerical performance against arrays.   Towards this end, wrote a partial matrix class and driver around it to test performance across C++, JVM (Java), and CLRs (C#) with both safe and unsafe implementations.

The code is essentially the same across these languages, with the exception that I included an unsafe variant (using pointers), to see what sort of additional performance could be obtained in the CLR.

On a linux box had the following runtimes (where Java is 1.7 and mono 2.10.6 with LLVM and without (same #s)):

CPP (Core i7-950):   			01:28:818
Java (Core i7-950):   			01:31.840 
Mono .NET (Core i7-950):  	04:01.466 (unsafe, LLVM)
Mono .NET (Core i7-950):  	04:29.680 (safe, LLVM)

Notice two things:

the mono runtimes are ~3x slower than the JVM or C++
the unsafe implementation offered very little performance improvement (why?)

So I decided to take a look at the MS .NET CLR on a VM and compare that with a C++ baseline (since the VM is slower):

CPP (VM): 					 01:56:296
.NET (VM): 					02:17.359 (unsafe, MS CLR)
.NET (VM): 					04.03.786 (safe, MS CLR)

Interestingly, the MS CLR is almost as fast as C++ with -O3 optimisations for the unsafe implementation.    The "safe" implementation is 2x as slow, in line with the idea that the unsafe implementation offers a significant performance advantage.

The "safe" implementations more or less align in that they are multiples slower than the C++ implementation (3x in the case of mono and 2x in the case of the MS CLR).  The mono implementation of the "unsafe" code shows very little performance benefit.

So I am wondering the following:

are there runtime or compile parameters that would increase the performance of the unsafe code?
is the cost of pinning the arrays expensive?
is it just a lack of JIT optimisation on the unsafe code?

I'm enclosing a source project with a csharp, java, and cpp sub-directory.   I hand compiled these, however, there is a sln that will compile the cpp and csharp parts.

Ideas?

Jonathan






-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20111119/7ec6de54/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: benchmark.tar.gz
Type: application/x-gzip
Size: 8842 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20111119/7ec6de54/attachment.gz 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20111119/7ec6de54/attachment-0001.html 


More information about the Mono-devel-list mailing list