What's the difference between ParallelOptions.MaxDegreeOfParallelism
and ParallelOptions.TaskScheduler.MaximumConcurrencyLevel
? When would you use either?
The MaxDegreeOfParallelism property affects the number of concurrent operations run by Parallel method calls that are passed this ParallelOptions instance. A positive property value limits the number of concurrent operations to the set value. If it is -1, there is no limit on the number of concurrently running operations.
The Max Degree of Parallelism (MDop) simply defines the number of processors/cores that SQL Server will use when the optimizer determines parallelism is needed. The Cost Threshold for Parallelism is cost threshold of when the SQL Server will use parallelism.
The Cost Threshold for Parallelism is cost threshold of when the SQL Server will use parallelism. The cost is the overall cost the optimizer determines for each query and SQL Server will use parallelism if the cost is above the threshold value. The recommended settings for MDop is the number of cores not to exceed 8.
Unlike TPL, comprehensive insurance is not required by law. However, it actually provides more protection to a motorist. Not only does it cover you from third party accident costs, but it also protects you and your passengers from liabilities.
Using reflector, I've gathered that both are used in EffectiveMaxConcurrencyLevel
property:
internal int EffectiveMaxConcurrencyLevel
{
get
{
int maxDegreeOfParallelism = this.MaxDegreeOfParallelism;
int maximumConcurrencyLevel = this.EffectiveTaskScheduler.MaximumConcurrencyLevel;
if ((maximumConcurrencyLevel > 0) && (maximumConcurrencyLevel != 0x7fffffff))
{
maxDegreeOfParallelism = (maxDegreeOfParallelism == -1) ? maximumConcurrencyLevel : Math.Min(maximumConcurrencyLevel, maxDegreeOfParallelism);
}
return maxDegreeOfParallelism;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With