Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net2 assemblies hosted in .Net4 app perform better in x86 than in AnyCpu mode?

I have a .Net4 WinForms app that references 3rd party .Net2 assemblies, which contain graphics-heavy visual controls. I've noticed a huge improvement in app's visual performance when I accidentally switched it from AnyCpu to x86 compilation mode. My development rig is a x64 Windows 7. The improvement is by a factor of at least two when controls are rendering their graphical elements.

Is this a known fact or am I doing something wrong?

like image 662
Boris B. Avatar asked Aug 23 '11 12:08

Boris B.


2 Answers

See these two articles about it:

AnyCPU Exes are usually more trouble than they're worth

Visual Studio: Why is there no 64 bit version? (yet)

See also this post about 64-bit code: Should I choose to take advantage of 64-bit?, it clearly states that for example Paint.NET works better under in 64-bit mode, because the developer optimized the code for 64-bit.

So, I don't think you are doing something wrong, but maybe the 3rd party .NET assemblies you're using could be improved specifically when running in a 64-bit process.

like image 153
Simon Mourier Avatar answered Sep 29 '22 07:09

Simon Mourier


This wouldn't surprise me. When you set the application to compile to "Any CPU", the CLR generates an application that the jiter on the user's machine must further compile to best fit their architecture. If you set it to "x86", your dev compiler compiles the application for an x86 machine, which reduces the load of the clients jiter.

like image 43
RLH Avatar answered Sep 29 '22 08:09

RLH