Degree of parallelism is the maximum number of ‘concurrently’ executing tasks that will be used to process the query. A query could become a long running one if it is waiting for a resource to be released or hardware to respond. PLINQ can parallelize this query by calling WithDegreeOfParallelism (which sets the maximum processor cores) after AsParallel().
AsParallel() method enables parallelization of a query.
The degreeOfParallelism is less than 1 or greater than 63. The WithDegreeOfParallelism method sets the degree of parallelism to use in a query. Let us see how to set the maximum number of processor cores to 3 using this method.
Depending on the number of cores you have, PLINQ may process that many chunks of data at once. So if you have a quadcore machine, it would be 4 threads. However remember that specifying WithDegreeOfParallelism as 8 on a quad core machine wouldn't really improve performance because only 4 threads could be active at the same time. Having said that, for File I/O ops, I usually specify a number greater than the number of cores.
Tweet
1 comment:
Mine is intel i3 processor.Total number of processors will be 4. If I provide WithDegreeOfParallelism(4) , my program will utilize all 4 processors. But even if i go for higher values like WithDegreeOfParallelism(344),WithDegreeOfParallelism(500),WithDegreeOfParallelism(510)......
etc. Then also its working.if count exceeds > 512, im getting error.
Available threads is 1023. So , whats logic behind this?
for WithDegreeOfParallelism(4) we should pass pass processors count means why it is accepting values 344,500,510,etc.....????
WithDegreeOfParallelism(int)?
Post a Comment