开发者

Identifying threads where Parallel.ForEach ran in Concurrency Visualizer

开发者 https://www.devze.com 2023-02-23 00:36 出处:网络
I\'m playing around with the concurrency visualize开发者_StackOverflowr in VS2010.It\'s a great feature but I am having trouble identifying the threads where my Parallel.ForEach ran.I\'m attaching a s

I'm playing around with the concurrency visualize开发者_StackOverflowr in VS2010. It's a great feature but I am having trouble identifying the threads where my Parallel.ForEach ran. I'm attaching a screenshot here in the hopes someone else can help. Also, does it appear that my application is running serially? Note the execution on the main thread and only one other worker thread.

Note: When I did this run I set the ParallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount (= 2).

Any help appreciated!

Identifying threads where Parallel.ForEach ran in Concurrency Visualizer


It looks like you application is using the main thread (it can inline work on the main thread) and switching between the three CLR worker threads near the bottom of this list. It's normal for different parts of the ForEach to be scheduler on different threads.

Click on one of the green (Execution blocks in one of these threads) to examine the class stack and see if it's really working on your ForEach. You should see something like:

System.Threading.Parallel...<PartitionerForEachWorker>...

near the top of the list.

You'll also see a grey scenario marker bar appear top and bottom of the view labelled "Parallel.ForEach" this is useful for seeing where your application was actually inside the code you're interested in.

The image is rather small so it's hard to tell more although there's a reasonable amount of yellow suggesting your threads are getting preempted (interupted by other work). This may be due to what you're doing inside the loop and/or other things going on in your application.

You can find more information on using the profiler with parallel applications here:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消