1+ /* Use coreinfo (utility by sysinternals) as this will give you
2+ a. Logical to Physical Processor Map
3+ b. Logical Processor to Socket Map
4+ c. Logical Processor to NUMA Node Map as below :
5+ Logical to Physical Processor Map:
6+ **---------------------- Physical Processor 0 (Hyperthreaded)
7+ --**-------------------- Physical Processor 1 (Hyperthreaded)
8+ ----**------------------ Physical Processor 2 (Hyperthreaded)
9+ ------**---------------- Physical Processor 3 (Hyperthreaded)
10+ --------**-------------- Physical Processor 4 (Hyperthreaded)
11+ ----------**------------ Physical Processor 5 (Hyperthreaded)
12+ ------------**---------- Physical Processor 6 (Hyperthreaded)
13+ --------------**-------- Physical Processor 7 (Hyperthreaded)
14+ ----------------**------ Physical Processor 8 (Hyperthreaded)
15+ ------------------**---- Physical Processor 9 (Hyperthreaded)
16+ --------------------**-- Physical Processor 10 (Hyperthreaded)
17+ ----------------------** Physical Processor 11 (Hyperthreaded)
18+ Logical Processor to Socket Map:
19+ ************------------ Socket 0
20+ ------------************ Socket 1
21+ Logical Processor to NUMA Node Map:
22+ ************------------ NUMA Node 0
23+ ------------************ NUMA Node 1
24+ Now, based on the above info, the Ideal MaxDop setting should be calculated as
25+ a. It has 12 CPU’s which are hyper threaded giving us 24 CPUs.
26+ b. It has 2 NUMA node [Node 0 and 1] each having 12 CPU’s with Hyperthreading ON.
27+ c. Number of sockets are 2 [socket 0 and 1] which are housing 12 CPU’s each.
28+ Considering all above factors, the max degree of Parallelism should be set to 6 which is ideal value for server with above configuration.
29+ So the answer is -- "it depends" on your processor footprint and the NUMA configuration and below table will summarize what I explained above:
30+ 8 or less processors ===> 0 to N (where N= no. of processors)
31+ More than 8 processors ===> 8
32+ NUMA configured ===> MAXDOP should not exceed no of CPU’s assigned to each
33+ NUMA node with max value capped to 8
34+ Hyper threading Enabled ===> Should not exceed the number of physical processors.
35+ Below is a quick and dirty TSQL script to generate Recommendation for MAXDOP setting
36+
37+ Author : Kin Shah
38+ Purpose : Recommend MaxDop settings for the server instance
39+ Tested RDBMS : SQL Server 2008R2 */
40+
41+ declare @hyperthreadingRatio bit
42+ declare @logicalCPUs int
43+ declare @HTEnabled int
44+ declare @physicalCPU int
45+ declare @SOCKET int
46+ declare @logicalCPUPerNuma int
47+ declare @NoOfNUMA int
48+
49+ select @logicalCPUs = cpu_count -- [Logical CPU Count]
50+ ,@hyperthreadingRatio = hyperthread_ratio -- [Hyperthread Ratio]
51+ ,@physicalCPU = cpu_count / hyperthread_ratio -- [Physical CPU Count]
52+ ,@HTEnabled = case
53+ when cpu_count > hyperthread_ratio
54+ then 1
55+ else 0
56+ end -- HTEnabled
57+ from sys .dm_os_sys_info
58+ option (recompile );
59+
60+ select @logicalCPUPerNuma = COUNT (parent_node_id) -- [NumberOfLogicalProcessorsPerNuma]
61+ from sys .dm_os_schedulers
62+ where [status] = ' VISIBLE ONLINE'
63+ and parent_node_id < 64
64+ group by parent_node_id
65+ option (recompile );
66+
67+ select @NoOfNUMA = count (distinct parent_node_id)
68+ from sys .dm_os_schedulers -- find NO OF NUMA Nodes
69+ where [status] = ' VISIBLE ONLINE'
70+ and parent_node_id < 64
71+
72+ -- Report the recommendations ....
73+ select
74+ -- - 8 or less processors and NO HT enabled
75+ case
76+ when @logicalCPUs < 8
77+ and @HTEnabled = 0
78+ then ' MAXDOP setting should be : ' + CAST (@logicalCPUs as varchar (3 ))
79+ -- - 8 or more processors and NO HT enabled
80+ when @logicalCPUs >= 8
81+ and @HTEnabled = 0
82+ then ' MAXDOP setting should be : 8'
83+ -- - 8 or more processors and HT enabled and NO NUMA
84+ when @logicalCPUs >= 8
85+ and @HTEnabled = 1
86+ and @NoofNUMA = 1
87+ then ' MaxDop setting should be : ' + CAST (@logicalCPUPerNuma / @physicalCPU as varchar (3 ))
88+ -- - 8 or more processors and HT enabled and NUMA
89+ when @logicalCPUs >= 8
90+ and @HTEnabled = 1
91+ and @NoofNUMA > 1
92+ then ' MaxDop setting should be : ' + CAST (@logicalCPUPerNuma / @physicalCPU as varchar (3 ))
93+ else ' '
94+ end as Recommendations
0 commit comments