Wednesday, September 5, 2007

New article at CodeProject - CompactMessageEncoder

I published a new article at CodeProject about compressing messages on WCF channels. Check it out here.

Ami

Monday, September 3, 2007

.NET Application runs faster as multi processed than multi threaded

I have simulation that does a lot of number crunching. I wanted to make it faster utilizing the CPU (I have a quad CPU). I tired to run the same algorithm it two ways:

  1. One process with several threads.
  2. Several process with one thread in each.

Each thread ran the same algorithm and internally spawn other threads.

I found out that the option 2 was faster than option 1. Looking into it I concluded that the first option spends too much time in the GC. Every time the GC runs it suspends all the threads of the process causing all the algorithms that run on the same process to stop.

By looking at the performance monitor the first option spends ~50% in GC, while the second option spends ~25% in GC.

Also checking the total time it took to run. The difference was higher as the number of algorithms run concurrently was higher.

 

Ami

Performance Counters of .NET x86 applications on x64 machine

When you compile a .NET application to x86 CPU and run it on 64-Bit machine, the performance counters are not displayed by the Performance Counter Monitor (perfmon) and the Process Explorer (Systinternals). This is very weird.

The solution for the Performance Counter Monitor is to run it:

mmc.exe /32 perfmon.msc

This way the mmc.exe runs a 32-Bit application an can see the Performance Counters of 32-Bit .NET application.

Note that it doesn't show the 64-Bit Performance Counter when using the /32 flag.

 

Ami