views:

53

answers:

1

Greetings.

I have a .NET application running a bunch of simulations in parallel. It's doing a parameter sweep, so each parameter has its own Parallel.Foreach loop. I normally set the max parallelism to one in all but one of loops, to keep memory requirements down, since each parameter can take more values than I have cores available (4).

The application is totally CPU bound, and only does I/O at the end, to write out results. I only have one lock around the data structure capturing the results, but that is accessed very seldom (once every few seconds). No matter how far I push the parallelism (by controlling the max parallelism on the loops) I always get an average CPU usage of about 50% (~ 2 cores).

I'd like to find out what prevents a higher CPU usage. My guesses are: 1) some call to .NET libraries that are synchronised, thus serialising the calls. 2) The GC stepping in to clean up resources (there's a lot garbage being produced by the application).

Any ideas how to go about the investigation?

Thanks a lot.

+1  A: 

I think debugging of multithreading issues always requires knowledge about code details, so there is not general recipe. But I think the GC is a very good first guess. Have you already tried this one:

http://msdn.microsoft.com/en-us/library/ms229357.aspx

I had a similar problem and using gcServer has allowed it to push the CPUs (8 cores) to it's limits.

Achim
Wow. That alone pushes CPU usage up to 75%. Memory seems to be stable. Keeping an eye on it. Thanks!
Mau