Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance improvements from upgrading .NET Framework

Tags:

.net

clr

I have a project written in .NET 4.0, and have no syntax or feature reason to upgrade it to .NET 4.5 . However, I was wondering if execution performance would improve.

Now, I understand that the IL code will probably remain the same, so performance improvements would come from CLR improvements. But as .NET 4.5 is still running the .NET 4.0 CLR, would there be any noticeable performance improvements by upgrading?

(For sake of completion/exposition, what about an upgrade from .NET 2 CLR to .NET 4 CLR?)

like image 260
Arithmomaniac Avatar asked Feb 17 '23 03:02

Arithmomaniac


2 Answers

Right, the CLR version number is still the same and the 4.5 CLR replaces the 4.0 CLR. The revision is however substantial. Short from the language projection that supports WinRT development, the focus for the 4.5 version was in fact on perf improvements.

I'll just briefly describe them, it is already well covered in this magazine article:

  • Multicore JIT. Which compiles IL to machine code on more than one core. Improves warm start time.
  • Profile guided optimization. Ngen.exe pays attention to instrumentation data collected in test runs to optimize the layout of the native code. It improves the cache locality of hot code.
  • Large Object Heap improvements. The LOH has traditionally had a memory fragmentation problem, improved for 4.5
  • Server GC background collections. Available for a while already on the workstation GC, now also supported for the server GC. Reduces the collection pauses.
  • Not mentioned in the article, using Reflection on .NET types is improved by pre-caching the type data for common .NET types.
  • Check the rest of the article for the other changes.
like image 192
Hans Passant Avatar answered Mar 20 '23 22:03

Hans Passant


The multicore JIT compiler is available only on 4.5. That alone could give you large performance improvement should you enable it.

It is worth mentioning that by going 4.5 you drop support for widnows xp (which might or might not be an issue).

like image 33
ghord Avatar answered Mar 20 '23 23:03

ghord