Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use Mono/LLVM to generate faster .NET applications than with Microsoft's C# compiler?

The Mono with LLVM project is able to use the LLVM compiler back-end which has some pretty powerful optimizations to compile a C# .NET project, which get it running about 20% faster in computationally intensive applications.

Mono is now able to use LLVM as a backend for code generation in addition to Mono's built-in JIT compiler. This allows Mono to benefit from all of the compiler optimizations done in LLVM. For example the SciMark score goes from 482 to 610.

So is it possible to target an existing C# .NET project to use Mono/LLVM in order to get faster applications for Windows or Unix? Is it quite that easy or would you have to refactor/modify the application code? Will this even work under the regular .NET Framework or is this specifically for the Mono Framework project? Considering this was stated:

This extra performance comes at a cost: it consumes more time and more memory to JIT compile using LLVM.

like image 353
Robin Rodricks Avatar asked Jul 30 '12 10:07

Robin Rodricks


People also ask

Does .NET use LLVM?

Llvm.NET uses the support of LibLLVM to gain access to the LLVM class library and project it into a . NET managed library that reflects the original class library design.

How is LLVM so fast?

That's because a VM with JIT is like a simulator that simulates a virtual computer, and also runs a compiler in realtime. Because both tasks are built into the VM with JIT, the machine simulator can feed information to the compiler so that the code can be recompiled to run more efficiently.

Is LLVM fast?

The website displays data from that repository. The server this runs on only has 2 cores, so a full LLVM build can take more than two hours. For smaller changes, building LLVM from ccache and compiling the benchmarks takes about 20 minutes.

Does Mono use LLVM?

Mono includes a backend which compiles methods to native code using LLVM instead of the built in JIT.


1 Answers

The LLVM backend is hooked into Mono's JIT compiler (the thing that converts the IL assembly to native assembly when you run the application), so you need to run the application with Mono.

like image 76
Ivan Zlatev Avatar answered Oct 23 '22 01:10

Ivan Zlatev