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.