Performance difference using entity structure in 32-bit and 64-bit

I am using Entity Framework in .NET Framework 4.0 in an application.

After updating the operating system to the 64-bit version, I noticed a higher processor load in the application.

Compiling the application specifically for x86 (instead of any processor, as before), the application returned to about the same CPU usage as before updating the operating system.

I took a few more detailed measurements using the code below

Some warm-up code is run before the overhead of creating the context for the first time and starting the request for the first time are not measured. These cases are not very interesting for my application, since this application is a long time

var s = Stopwatch.StartNew(); var name = "name"; for (var i = 0; i < 100000; ++i) { using (var context = new MyDatabaseEntities()) { var entity = context.MyEntities.FirstOrDefault(e => e.Name == name); } } s.Stop(); 

The code compiled above for x86 or x64 (any processor gives the same results as x64) and runs on a 64-bit Windows 7 machine. (The database runs on a different machine)

Gives 12% performance difference in favor of x86s. That is, if the x86 version starts 100 requests per second, then the x64 version starts 88 requests per second.

Is this the expected / normal performance difference between 32bit and 64bit on .NET?

Is there something I can do to get the same performance in the 64-bit version as in the 32-bit version?

In the above example, MyEntity is a very simple entity with id and name

Typically, an application starts as a Windows service, but when measured, it starts as a regular Windows application (WPF)

+4
source share
2 answers

Do you get the same entity again and again agian? What exactly are you trying to check. A real application tends to behave differently than your test. Make a real Senario where you have different entities and you will get different results. You should only check this if you know how your application will be used. An application that uses more memory will usually work better on 64-bit. In your case, memory usage is likely to be low, so you get better 32-bit performance.

-1
source

In my case, I am using asp.net and x86 due to memory usage below 2gb. X64 doubles memory usage, but you can allocate more than 2 GB. Here is a similar question: x64 vs x86 Performance Recommendations. Net

-1
source

All Articles