views:

27

answers:

1

I was experimenting a lot with application profiling lately (using Visual Studio Performance Wizard). While working with Concurrency indicators, I've noticed the fact that when the application runs with multiple threads (both background and foreground) the cross-core context switch rate is quite high.

Knowing that generally a large number of cross-core context switches can be detrimental to application performance, I would like to reduce it to a minimum.

What would be the possible ways to do this in a .NET application besides minimizing the number of simultaneously running threads?

+1  A: 

You could affinitize some of those threads to a single core. But you have to be extremely careful when doing so - as it may actually reduce performance by preventing the CLR/OS from scheduling threads to available cores.

To do so, you can use the BeginThreadAffinity method to force the thread to remain pinned to the identity of a particular processor or core.

LBushkin