[Mono-dev] Unsafe code performance on Mono
Sergio Luis Para
sluisp at codicesoftware.com
Fri Feb 12 16:12:09 UTC 2016
Thank you for your response, Vladimir.
> Could you please provide detailed step-by-step instructions on how you got those results, or (ideally) a self-contained benchmark that would expose that difference?
I coded a simple example that performs three compress-decompress cycles, measuring only the compression time and ignoring the I/O one. It can be found here https://github.com/SergioLuis/lz4-unsafe-performance-test
The file I used to run the test is a ~100MB one that is representative of the kind of data we need to compress, in order to make the results relevant. It can be found here https://www.dropbox.com/s/zo7imitrn5ka4ss/datasample.bin?dl=0 if you want to repeat the test in the exact same conditions.
I repeated the tests on three virtual machines (Windows 8.1 x64, Fedora 20 x86, Ubuntu 15.04 x64) with the exact same configuration (4 virtual cores, 2GB RAM) on a Intel Core i7 4790 CPU.
These are the results from the Windows VM (.NET 4.5.1)
______
Compressed 104000707 bytes to 73555650 bytes in 422 ms.
Decompressed 73555650 bytes to 104000707 bytes in 63 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 562 ms.
Decompressed 73555650 bytes to 104000707 bytes in 47 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 563 ms.
Decompressed 73555650 bytes to 104000707 bytes in 47 ms.
====================
______
These are the results from the Fedora 20 machine under Mono 4.3.0 without LLVM
______
[tester at localhost ~]$ /opt/plasticscm5/mono/bin/mono LZ4UnsafePerformanceTest.exe datasample.bin
Compressed 104000707 bytes to 73555650 bytes in 1954 ms.
Decompressed 73555650 bytes to 104000707 bytes in 69 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 1149 ms.
Decompressed 73555650 bytes to 104000707 bytes in 67 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 1118 ms.
Decompressed 73555650 bytes to 104000707 bytes in 66 ms.
====================
[tester at localhost ~]$ /opt/plasticscm5/mono/bin/mono -V
Mono JIT compiler version 4.3.0 (tarball Wed Nov 25 17:41:18 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
______
These are the results on the exact same machine under Mono 2.10.8
______
[tester at localhost ~]$ mono --llvm LZ4UnsafePerformanceTest.exe datasample.bin
Compressed 104000707 bytes to 73555650 bytes in 621 ms.
Decompressed 73555650 bytes to 104000707 bytes in 66 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 623 ms.
Decompressed 73555650 bytes to 104000707 bytes in 65 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 619 ms.
Decompressed 73555650 bytes to 104000707 bytes in 65 ms.
====================
[tester at localhost ~]$ mono -V
Mono JIT compiler version 2.10.8 (tarball Sat Aug 3 13:21:11 UTC 2013)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: debugger softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
______
As you can see, Mono 2.10.8 runs the tests in almost half the time than 4.3.0.
These are the results on a Ubuntu 15.04 machine with Mono 3.2.8
______
tester at ubuntu:~/Desktop$ mono --nollvm --sgen LZ4UnsafePerformanceTest.exe datasample.bin
Compressed 104000707 bytes to 73555650 bytes in 1193 ms.
Decompressed 73555650 bytes to 104000707 bytes in 99 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 938 ms.
Decompressed 73555650 bytes to 104000707 bytes in 98 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 1203 ms.
Decompressed 73555650 bytes to 104000707 bytes in 99 ms.
====================
tester at ubuntu:~/Desktop$ mono --llvm --sgen LZ4UnsafePerformanceTest.exe datasample.bin
Compressed 104000707 bytes to 73555650 bytes in 968 ms.
Decompressed 73555650 bytes to 104000707 bytes in 99 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 953 ms.
Decompressed 73555650 bytes to 104000707 bytes in 97 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 1202 ms.
Decompressed 73555650 bytes to 104000707 bytes in 96 ms.
====================
tester at ubuntu:~/Desktop$ mono -V
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4ubuntu4)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
______
Because none of the above had LLVM support on the available Mono installations, I cloned the Mono and LLVM repositories and compiled and installed them from source, following these instructions in order to enable LLVM support. http://www.mono-project.com/docs/advanced/mono-llvm/
These are the results, with and without LLVM, on a virtual machine running Lubuntu 15.04 (4 virtual processor on a Intel Core i5 3337U), using Mono 4.3.3
______
sergio at sergio-VirtualBox:~/Descargas$ mono LZ4UnsafePerformanceTest.exe Release/datasample.bin
Compressed 104000707 bytes to 73555650 bytes in 1718 ms.
Decompressed 73555650 bytes to 104000707 bytes in 189 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 1678 ms.
Decompressed 73555650 bytes to 104000707 bytes in 164 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 1620 ms.
Decompressed 73555650 bytes to 104000707 bytes in 163 ms.
====================
sergio at sergio-VirtualBox:~/Descargas$ mono --llvm LZ4UnsafePerformanceTest.exe Release/datasample.bin
Compressed 104000707 bytes to 73555650 bytes in 381 ms.
Decompressed 73555650 bytes to 104000707 bytes in 71 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 330 ms.
Decompressed 73555650 bytes to 104000707 bytes in 47 ms.
====================
Compressed 104000707 bytes to 73555650 bytes in 338 ms.
Decompressed 73555650 bytes to 104000707 bytes in 48 ms.
====================
sergio at sergio-VirtualBox:~/Descargas$ mono -V
Mono JIT compiler version 4.3.3 (master/6fae7c2 vie feb 12 00:09:47 CET 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: yes(3.6.0svn-mono-master/9f79399)
GC: sgen
______
So, apparently LLVM does the trick (where available), but without it, performance is severely affected for the C# unsafe code. I'm quite surprised about the results on the fedora 20 machine with Mono 2.10.8, impressively fast compared to the ones that Mono 4.3.0 achieved on the very same machine.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20160212/e5c100d3/attachment-0001.html>
More information about the Mono-devel-list
mailing list