SQL Server의 MAXDOP 설정 알고리즘


67

새 SQL Server를 설정할 때 다음 코드를 사용하여 MAXDOP설정 의 좋은 시작점을 결정 합니다.

/* 
   This will recommend a MAXDOP setting appropriate for your machine's NUMA memory
   configuration.  You will need to evaluate this setting in a non-production 
   environment before moving it to production.

   MAXDOP can be configured using:  
   EXEC sp_configure 'max degree of parallelism',X;
   RECONFIGURE

   If this instance is hosting a Sharepoint database, you MUST specify MAXDOP=1 
   (URL wrapped for readability)
   http://blogs.msdn.com/b/rcormier/archive/2012/10/25/
   you-shall-configure-your-maxdop-when-using-sharepoint-2013.aspx

   Biztalk (all versions, including 2010): 
   MAXDOP = 1 is only required on the BizTalk Message Box
   database server(s), and must not be changed; all other servers hosting other 
   BizTalk Server databases may return this value to 0 if set.
   http://support.microsoft.com/kb/899000
*/


DECLARE @CoreCount int;
DECLARE @NumaNodes int;

SET @CoreCount = (SELECT i.cpu_count from sys.dm_os_sys_info i);
SET @NumaNodes = (
    SELECT MAX(c.memory_node_id) + 1 
    FROM sys.dm_os_memory_clerks c 
    WHERE memory_node_id < 64
    );

IF @CoreCount > 4 /* If less than 5 cores, don't bother. */
BEGIN
    DECLARE @MaxDOP int;

    /* 3/4 of Total Cores in Machine */
    SET @MaxDOP = @CoreCount * 0.75; 

    /* if @MaxDOP is greater than the per NUMA node
       Core Count, set @MaxDOP = per NUMA node core count
    */
    IF @MaxDOP > (@CoreCount / @NumaNodes) 
        SET @MaxDOP = (@CoreCount / @NumaNodes) * 0.75;

    /*
        Reduce @MaxDOP to an even number 
    */
    SET @MaxDOP = @MaxDOP - (@MaxDOP % 2);

    /* Cap MAXDOP at 8, according to Microsoft */
    IF @MaxDOP > 8 SET @MaxDOP = 8;

    PRINT 'Suggested MAXDOP = ' + CAST(@MaxDOP as varchar(max));
END
ELSE
BEGIN
    PRINT 'Suggested MAXDOP = 0 since you have less than 4 cores total.';
    PRINT 'This is the default setting, you likely do not need to do';
    PRINT 'anything.';
END

나는 이것이 약간 주관적이며 많은 것들에 따라 다를 수 있다는 것을 알고 있습니다. 그러나 나는 새로운 서버의 출발점으로 사용할 엄격한 코드를 만들려고합니다.

누구 든지이 코드에 대한 입력이 있습니까?


1
프로세서가 4 개인 기본값에 대한 권장 사항은 2입니다. 0은 무제한으로 설정합니다. MAXDOP를 설정하는 동안 병렬 처리 비용 임계 값 (일명 CTFP)을 40과 75 사이의 값으로 조정하는 것이 좋습니다. {내가 가장 좋아하는 초기 설정은 42입니다. 인식}
— yeOldeDataSmythe

42는 결국 모든 것에 대한 해답입니다. 예를 들어이 게시물의 조회수는 44,000 회입니다.
— Max Vernon

답변:


49

가장 좋은 방법은-coreinfo (sysinternals의 유틸리티)를 사용하는 것입니다.

a. Logical to Physical Processor Map
b. Logical Processor to Socket Map
c. Logical Processor to NUMA Node Map as below :

Logical to Physical Processor Map:
**----------------------  Physical Processor 0 (Hyperthreaded)
--**--------------------  Physical Processor 1 (Hyperthreaded)
----**------------------  Physical Processor 2 (Hyperthreaded)
------**----------------  Physical Processor 3 (Hyperthreaded)
--------**--------------  Physical Processor 4 (Hyperthreaded)
----------**------------  Physical Processor 5 (Hyperthreaded)
------------**----------  Physical Processor 6 (Hyperthreaded)
--------------**--------  Physical Processor 7 (Hyperthreaded)
----------------**------  Physical Processor 8 (Hyperthreaded)
------------------**----  Physical Processor 9 (Hyperthreaded)
--------------------**--  Physical Processor 10 (Hyperthreaded)
----------------------**  Physical Processor 11 (Hyperthreaded)

Logical Processor to Socket Map:
************------------  Socket 0
------------************  Socket 1

Logical Processor to NUMA Node Map:
************------------  NUMA Node 0
------------************  NUMA Node 1

위의 정보를 바탕으로 이상적인 MaxDop 설정은 다음과 같이 계산되어야합니다.

a.  It has 12 CPU’s which are hyper threaded giving us 24 CPUs.
b.  It has 2 NUMA node [Node 0 and 1] each having 12 CPU’s with Hyperthreading ON.
c.  Number of sockets are 2 [socket 0 and 1] which are housing 12 CPU’s each.

Considering all above factors, the max degree of Parallelism should be set to 6 which is ideal value for server with above configuration.

따라서 답은 프로세서 풋 프린트와 NUMA 구성 및 아래 표에 따라 ""에 따라 다릅니다 . 위에서 설명한 내용을 요약합니다.

8 or less processors    ===> 0 to N (where N= no. of processors)
More than 8 processors  ===> 8
NUMA configured         ===> MAXDOP should not exceed no of CPU’s assigned to each 
                                 NUMA node with max value capped to 8
Hyper threading Enabled ===> Should not exceed the number of physical processors.

편집 : 아래는 MAXDOP 설정에 대한 권장 사항을 생성하는 빠르고 더러운 TSQL 스크립트입니다.

/*************************************************************************
Author          :   Kin Shah
Purpose         :   Recommend MaxDop settings for the server instance
Tested RDBMS    :   SQL Server 2008R2

**************************************************************************/
declare @hyperthreadingRatio bit
declare @logicalCPUs int
declare @HTEnabled int
declare @physicalCPU int
declare @SOCKET int
declare @logicalCPUPerNuma int
declare @NoOfNUMA int

select @logicalCPUs = cpu_count -- [Logical CPU Count]
    ,@hyperthreadingRatio = hyperthread_ratio --  [Hyperthread Ratio]
    ,@physicalCPU = cpu_count / hyperthread_ratio -- [Physical CPU Count]
    ,@HTEnabled = case 
        when cpu_count > hyperthread_ratio
            then 1
        else 0
        end -- HTEnabled
from sys.dm_os_sys_info
option (recompile);

select @logicalCPUPerNuma = COUNT(parent_node_id) -- [NumberOfLogicalProcessorsPerNuma]
from sys.dm_os_schedulers
where [status] = 'VISIBLE ONLINE'
    and parent_node_id < 64
group by parent_node_id
option (recompile);

select @NoOfNUMA = count(distinct parent_node_id)
from sys.dm_os_schedulers -- find NO OF NUMA Nodes 
where [status] = 'VISIBLE ONLINE'
    and parent_node_id < 64

-- Report the recommendations ....
select
    --- 8 or less processors and NO HT enabled
    case 
        when @logicalCPUs < 8
            and @HTEnabled = 0
            then 'MAXDOP setting should be : ' + CAST(@logicalCPUs as varchar(3))
                --- 8 or more processors and NO HT enabled
        when @logicalCPUs >= 8
            and @HTEnabled = 0
            then 'MAXDOP setting should be : 8'
                --- 8 or more processors and HT enabled and NO NUMA
        when @logicalCPUs >= 8
            and @HTEnabled = 1
            and @NoofNUMA = 1
            then 'MaxDop setting should be : ' + CAST(@logicalCPUPerNuma / @physicalCPU as varchar(3))
                --- 8 or more processors and HT enabled and NUMA
        when @logicalCPUs >= 8
            and @HTEnabled = 1
            and @NoofNUMA > 1
            then 'MaxDop setting should be : ' + CAST(@logicalCPUPerNuma / @physicalCPU as varchar(3))
        else ''
        end as Recommendations

편집 : 미래 방문자를 위해, 당신은 test-dbamaxdop powershell 기능을 볼 수 있습니다 ( 다른 매우 유용한 DBA 기능 과 함께 ) (ALL FREE !!).


cpu_count> hyperthread_ratio가 1이면 0이 끝날 때 이것이 사실입니까? 8 개의 논리적 프로세서, 8 개의 물리적 프로세서 및 1 개의 hyperthread_ratio의 경우 그것은 여전히 ​​믿기 어려운 하이퍼 스레드가 활성화되어 있다고 말합니다. 그리고이 경우 MAXDOP도 1로 표시되며 사실이 아닙니다.
— UdIt Solanki

@UdItSolanki 올바른 방법은 coreinfo를 사용하여 HT가 활성화되어 있는지 여부를 확인하는 것입니다. TSQL을 사용하여 HT가 활성화되어 있는지를 알 수있는 확실한 방법은 없습니다. test-dbamaxdop내 대답에 언급 된대로 시도 했습니까 ?
— Kin Shah

17

MAXDOP를 설정할 때 일반적으로 NUMA 노드의 코어 수로 제한하려고합니다. 그렇게하면 일정이 numa 노드의 메모리에 액세스하려고하지 않습니다.


13

MSDN 팀 의 게시물을 살펴보면 머신에서 물리적 코어 수를 안정적으로 가져 와서 우수한 MAXDOP 설정을 결정하는 방법을 찾았습니다.

"좋은"이라는 말은 보수적 인 것을 의미합니다. 즉, NUMA 노드에서 코어의 최대 75 % 또는 전체 최대 8 개의 코어를 사용해야합니다.

소켓 당 실제 코어 수, 소켓 수 및 NUMA 노드 수에 대한 SQL Server 2016 (13.x) SP2 이상 및 모든 버전의 SQL Server 2017 이상에 대한 세부 정보는 기준을 결정하는 깔끔한 방법을 허용합니다 새 SQL Server 설치를위한 MAXDOP 설정

위에서 언급 한 버전의 경우이 코드는 NUMA 노드에있는 물리적 코어 수의 75 %를 보수적 인 MAXDOP 설정으로 권장합니다.

DECLARE @socket_count int;
DECLARE @cores_per_socket int;
DECLARE @numa_node_count int;
DECLARE @memory_model nvarchar(120);
DECLARE @hyperthread_ratio int;

SELECT @socket_count = dosi.socket_count
       , @cores_per_socket = dosi.cores_per_socket
       , @numa_node_count = dosi.numa_node_count
       , @memory_model = dosi.sql_memory_model_desc
       , @hyperthread_ratio = dosi.hyperthread_ratio
FROM sys.dm_os_sys_info dosi;

SELECT [Socket Count] = @socket_count
       , [Cores Per Socket] = @cores_per_socket
       , [Number of NUMA nodes] = @numa_node_count
       , [Hyperthreading Enabled] = CASE WHEN @hyperthread_ratio > @cores_per_socket THEN 1 ELSE 0 END
       , [Lock Pages in Memory granted?] = CASE WHEN @memory_model = N'CONVENTIONAL' THEN 0 ELSE 1 END;

DECLARE @MAXDOP int = @cores_per_socket;
SET @MAXDOP = @MAXDOP * 0.75;
IF @MAXDOP >= 8 SET @MAXDOP = 8;

SELECT [Recommended MAXDOP setting] = @MAXDOP
       , [Command] = 'EXEC sys.sp_configure N''max degree of parallelism'', ' + CONVERT(nvarchar(10), @MAXDOP) + ';RECONFIGURE;';

SQL Server 2017 또는 SQL Server 2016 SP2 이전의 SQL Server 버전의 경우에서 노드 당 코어 수를 얻을 수 없습니다 sys.dm_os_sys_info. 대신 PowerShell을 사용하여 물리적 코어 수를 확인할 수 있습니다.

powershell -OutputFormat Text -NoLogo -Command "& {Get-WmiObject -namespace 
"root\CIMV2" -class Win32_Processor -Property NumberOfCores} | select NumberOfCores"

또한 PowerShell을 사용하여 논리적 코어 수를 결정할 수 있습니다. HyperThreading이 켜져있는 경우 물리적 코어 수의 두 배가 될 수 있습니다.

powershell -OutputFormat Text -NoLogo -Command "& {Get-WmiObject -namespace 
"root\CIMV2" -class Win32_Processor -Property NumberOfCores} 
| select NumberOfLogicalProcessors"

T-SQL :

/* 
   This will recommend a MAXDOP setting appropriate for your machine's NUMA memory
   configuration.  You will need to evaluate this setting in a non-production 
   environment before moving it to production.

   MAXDOP can be configured using:  
   EXEC sp_configure 'max degree of parallelism',X;
   RECONFIGURE

   If this instance is hosting a Sharepoint database, you MUST specify MAXDOP=1 
   (URL wrapped for readability)
   http://blogs.msdn.com/b/rcormier/archive/2012/10/25/
   you-shall-configure-your-maxdop-when-using-sharepoint-2013.aspx

   Biztalk (all versions, including 2010): 
   MAXDOP = 1 is only required on the BizTalk Message Box
   database server(s), and must not be changed; all other servers hosting other 
   BizTalk Server databases may return this value to 0 if set.
   http://support.microsoft.com/kb/899000
*/
SET NOCOUNT ON;

DECLARE @CoreCount int;
SET @CoreCount = 0;
DECLARE @NumaNodes int;

/*  see if xp_cmdshell is enabled, so we can try to use 
    PowerShell to determine the real core count
*/
DECLARE @T TABLE (
    name varchar(255)
    , minimum int
    , maximum int
    , config_value int
    , run_value int
);
INSERT INTO @T 
EXEC sp_configure 'xp_cmdshell';
DECLARE @cmdshellEnabled BIT;
SET @cmdshellEnabled = 0;
SELECT @cmdshellEnabled = 1 
FROM @T
WHERE run_value = 1;
IF @cmdshellEnabled = 1
BEGIN
    CREATE TABLE #cmdshell
    (
        txt VARCHAR(255)
    );
    INSERT INTO #cmdshell (txt)
    EXEC xp_cmdshell 'powershell -OutputFormat Text -NoLogo -Command "& {Get-WmiObject -namespace "root\CIMV2" -class Win32_Processor -Property NumberOfCores} | select NumberOfCores"';
    SELECT @CoreCount = CONVERT(INT, LTRIM(RTRIM(txt)))
    FROM #cmdshell
    WHERE ISNUMERIC(LTRIM(RTRIM(txt)))=1;
    DROP TABLE #cmdshell;
END
IF @CoreCount = 0 
BEGIN
    /* 
        Could not use PowerShell to get the corecount, use SQL Server's 
        unreliable number.  For machines with hyperthreading enabled
        this number is (typically) twice the physical core count.
    */
    SET @CoreCount = (SELECT i.cpu_count from sys.dm_os_sys_info i); 
END

SET @NumaNodes = (
    SELECT MAX(c.memory_node_id) + 1 
    FROM sys.dm_os_memory_clerks c 
    WHERE memory_node_id < 64
    );

DECLARE @MaxDOP int;

/* 3/4 of Total Cores in Machine */
SET @MaxDOP = @CoreCount * 0.75; 

/* if @MaxDOP is greater than the per NUMA node
    Core Count, set @MaxDOP = per NUMA node core count
*/
IF @MaxDOP > (@CoreCount / @NumaNodes) 
    SET @MaxDOP = (@CoreCount / @NumaNodes) * 0.75;

/*
    Reduce @MaxDOP to an even number 
*/
SET @MaxDOP = @MaxDOP - (@MaxDOP % 2);

/* Cap MAXDOP at 8, according to Microsoft */
IF @MaxDOP > 8 SET @MaxDOP = 8;

PRINT 'Suggested MAXDOP = ' + CAST(@MaxDOP as varchar(max));

스크립트를 실행했으며 MAXDOP = 0을 추천했습니다. 4 개의 NUMA 노드, HT enbaled, 4 개의 코어 당 20 개의 논리 프로세서를 믿기 어렵습니다. 왜 그런지 알아?
— BeginnerDBA

@BeginnerDBA-어떤 SQL Server 버전을 사용하고 있습니까?
— Max Vernon

SQL Server 2012 및 SQL2014에서 테스트 한 경우와 유사
— BeginnerDBA

SQL Server가 VM에서 실행되고 있습니까? numa 노드 당 코어 수가 1 인 것 같습니다. 아마도 VM이 이상하게 구성되어 있습니까? 디버깅 목적으로 스크립트 끝에 이것을 추가 할 수 있습니다. SELECT [@CoreCount] = @CoreCount , [@NumaNodes] = @NumaNodes , [@MaxDOP] = @MaxDOP
— Max Vernon

감사. 물리적 서버 인 Nope도 추가해 보도록하겠습니다
— BeginnerDBA

11

일반적으로 OLAP 시스템에는 더 높은 DOP를 사용하고 OLTP 시스템에는 더 낮은 DOP를 사용하십시오. 많은 시스템이 중간에 있으므로 OLTP 워크로드를 방해하지 않으면 서 가끔 큰 워크로드가 충분한 CPU를 신속하게 완료 할 수있는 유용한 매체를 찾으십시오.

또한 cpu_count열을 사용하여 코어 수를 얻을 때주의하십시오 . 하이퍼 스레딩이 활성화 된 경우이 열에는 노출 된 논리 프로세서 수가 반영됩니다. 일반적으로 DOP가 실제 코어 수보다 높으면 안됩니다. 논리 프로세서에 많은 병렬 워크로드를 분산 시키면 실질적인 이점없이 오버 헤드가 증가합니다.

거기이기도 hyperthread_ratio열,하지만 나는 그것이 무엇을 나타내는 지 확실하지 않다. 설명서도 명확하지 않습니다. 시스템에서 볼 수있는 숫자는 전체 시스템의 물리적 코어 수 또는 칩당 논리 프로세서 수를 나타냅니다. 문서는 내가 완전히 다른 모습을보아야한다고 주장합니다.


1
hyperthread_ratio프로세서 당 논리 코어의 양 이라고 생각합니다 . 나는 잠시 동안 그 문제에 부딪쳤다. 그리고 내가 올바르게 기억된다면 그것은 내가 온 결론이다. 아마 @AaronBertrand에 대한 자세한 정보가 있습니다. 아직 검증하기 전에 어렵고 빠른 사실로 생각하지 마십시오.
— Thomas Stringer

@ThomasStringer 설명서에는 여러 컴퓨터에서 문서를 실행했을 때의 모습이 나와 있습니다. 그러나 하이퍼 스레딩이 실제로 활성화되어 있는지 여부를 해당 열에서 확인하는 것은 매우 어렵습니다. 예를 들어, 내 서버 중 하나에서 8을보고합니다. 서버에는 2 개의 물리적 CPU가 있고 각 CPU에 4 개의 코어가 있으며 하이퍼 스레딩이 활성화되어 있습니다. 하이퍼 스레딩이없는 컴퓨터에서는 같은 상황에서 4를보고하지만 재부팅 (및 하이퍼 스레딩을 끄지 않은 상태)하면 해당 변경 사항을 볼 수 없습니다!
— Max Vernon

7

또한 기사 http://support.microsoft.com/kb/2806535 에 대해 우연히 발견했으며 위의 스크립트와의 상관 관계를 찾을 수 없습니다.

또한 왜 "@logicalCPUs> = 8 및 @HTEnabled = 1 및 @NoofNUMA = 1"및 "@logicalCPUs> = 8 및 @HTEnabled = 1 및 @NoofNUMA> 1"에 대한 차별화가 있는지 궁금합니다. 동일하게됩니다.

결국 나는 위의 기사와 일치하는 내 자신의 코드 조각을 작성했지만 결국 "프로세서" "CPU"및 "물리적 프로세서"에 대한 더 정확한 정의 및 / 또는 차별화를 좋아했을 것입니다.

그것으로 당신의 스핀을 자유롭게 느끼십시오.

/*************************************************************************
Author          :   Dennis Winter (Thought: Adapted from a script from "Kin Shah")
Purpose         :   Recommend MaxDop settings for the server instance
Tested RDBMS    :   SQL Server 2008R2

**************************************************************************/
declare @hyperthreadingRatio bit
declare @logicalCPUs int
declare @HTEnabled int
declare @physicalCPU int
declare @SOCKET int
declare @logicalCPUPerNuma int
declare @NoOfNUMA int
declare @MaxDOP int

select @logicalCPUs = cpu_count -- [Logical CPU Count]
    ,@hyperthreadingRatio = hyperthread_ratio --  [Hyperthread Ratio]
    ,@physicalCPU = cpu_count / hyperthread_ratio -- [Physical CPU Count]
    ,@HTEnabled = case 
        when cpu_count > hyperthread_ratio
            then 1
        else 0
        end -- HTEnabled
from sys.dm_os_sys_info
option (recompile);

select @logicalCPUPerNuma = COUNT(parent_node_id) -- [NumberOfLogicalProcessorsPerNuma]
from sys.dm_os_schedulers
where [status] = 'VISIBLE ONLINE'
    and parent_node_id < 64
group by parent_node_id
option (recompile);

select @NoOfNUMA = count(distinct parent_node_id)
from sys.dm_os_schedulers -- find NO OF NUMA Nodes 
where [status] = 'VISIBLE ONLINE'
    and parent_node_id < 64

IF @NoofNUMA > 1 AND @HTEnabled = 0
    SET @MaxDOP= @logicalCPUPerNuma 
ELSE IF  @NoofNUMA > 1 AND @HTEnabled = 1
    SET @MaxDOP=round( @NoofNUMA  / @physicalCPU *1.0,0)
ELSE IF @HTEnabled = 0
    SET @MaxDOP=@logicalCPUs
ELSE IF @HTEnabled = 1
    SET @MaxDOP=@physicalCPU

IF @MaxDOP > 10
    SET @MaxDOP=10
IF @MaxDOP = 0
    SET @MaxDOP=1

PRINT 'logicalCPUs : '         + CONVERT(VARCHAR, @logicalCPUs)
PRINT 'hyperthreadingRatio : ' + CONVERT(VARCHAR, @hyperthreadingRatio) 
PRINT 'physicalCPU : '         + CONVERT(VARCHAR, @physicalCPU) 
PRINT 'HTEnabled : '           + CONVERT(VARCHAR, @HTEnabled)
PRINT 'logicalCPUPerNuma : '   + CONVERT(VARCHAR, @logicalCPUPerNuma) 
PRINT 'NoOfNUMA : '            + CONVERT(VARCHAR, @NoOfNUMA)
PRINT '---------------------------'
Print 'MAXDOP setting should be : ' + CONVERT(VARCHAR, @MaxDOP)

좋은 코드 조각. 난 당신이 실현 있는지 확실하지 않습니다 hyperthread_ratio에 열을 sys.dm_os_sys_info내 워크 스테이션에 ... 오해의 소지가있다, 예를 들어, 내가 활성화 하이퍼 스레딩 단일 4 코어 CPU가 - 작업 관리자 8 개 논리적 CPU를보고, 당신의 코드에 하이퍼 스레딩 비율을보고 1. 수
— 최대 버논

참고로 내 코드는이 기계에 대해 6 권장 사항을 생성하므로 가장 스트레스가 많은 병렬 쿼리에서도 2 개의 코어를 사용할 수 있습니다.
— Max Vernon

hyperthread_ratio는 실제로 문제이지만 적어도 내 지식으로는 더 잘 해결할 수는 없습니다. 자세한 내용은이 블로그를 참조하십시오 : sqlblog.com/blogs/kalen_delaney/archive/2007/12/08/… 그리고 두 번째 게시물에 대해- "최대 병렬성 수준"에 대해 어떤 값을 선택했는지 알고 싶습니다. 당신의 기계를 위해. :-D 나는 또한이 주제에 대해 아주 새롭습니다. 나는 이전에 몰랐고이 정보가 필요했기 때문에 이것에 대해 우연히 발견했습니다. 따라서 당신의 결론은 무엇입니까, 2 개의 코어가 여전히 좋은 것입니까, 나쁜 것입니까?
— 데니스 겨울

4

이 버전은 기존 MAXDOP 설정으로 멋진 단일 결과 집합을 제공하며 xp_cmdshell을 사용할 필요없이 SQL 2008-2017 버전을 유지해야합니다.

select
[ServerName]                    = @@SERVERNAME
, [ComputerName]                = SERVERPROPERTY('ComputerNamePhysicalNetBIOS') 
, [LogicalCPUs]             
, hyperthread_ratio 
, [PhysicalCPU]             
, [HTEnabled]               
, LogicalCPUPerNuma
, [NoOfNUMA]
, [MaxDop_Recommended]          = convert(int,case when [MaxDop_RAW] > 10 then 10 else [MaxDop_RAW] end)
, [MaxDop_Current]              = sc.value
, [MaxDop_RAW]
, [Number of Cores] 
from
(
select
     [LogicalCPUs]              
    , hyperthread_ratio 
    , [PhysicalCPU]             
    , [HTEnabled]               
    , LogicalCPUPerNuma
    , [NoOfNUMA]
    , [Number of Cores] 
    , [MaxDop_RAW]              = 
        case
            when [NoOfNUMA] > 1 AND HTEnabled = 0 then logicalCPUPerNuma 
            when [NoOfNUMA] > 1 AND HTEnabled = 1 then convert(decimal(9,4),[NoOfNUMA]/ convert(decimal(9,4),Res_MAXDOP.PhysicalCPU) * convert(decimal(9,4),1))
            when HTEnabled = 0 then  Res_MAXDOP.LogicalCPUs
            when HTEnabled = 1 then  Res_MAXDOP.PhysicalCPU
        end
from
(
    select
         [LogicalCPUs]              = osi.cpu_count
        , osi.hyperthread_ratio 
        , [PhysicalCPU]             = osi.cpu_count/osi.hyperthread_ratio
        , [HTEnabled]               = case when osi.cpu_count > osi.hyperthread_ratio then 1 else 0 end
        , LogicalCPUPerNuma
        , [NoOfNUMA]
        , [Number of Cores] 
    from 
    (
        select
            [NoOfNUMA]  = count(res.parent_node_id)
            ,[Number of Cores]  = res.LogicalCPUPerNuma/count(res.parent_node_id)
            ,res.LogicalCPUPerNuma
        from
        (
            Select
                s.parent_node_id
                ,LogicalCPUPerNuma  = count(1)
            from
                sys.dm_os_schedulers s
            where
                s.parent_node_id < 64
                and
                s.status = 'VISIBLE ONLINE'
            group by 
                s.parent_node_id
        ) Res
        group by
            res.LogicalCPUPerNuma
    ) Res_NUMA
    cross apply sys.dm_os_sys_info osi
) Res_MAXDOP
)Res_Final
cross apply sys.sysconfigures sc
where sc.comment = 'maximum degree of parallelism'
option (recompile);

3

멋진 스크립트이지만 kb 기사 : http://support.microsoft.com/kb/2806535 는 코드와 완벽하게 일치하지 않습니다. 내가 무엇을 놓치고 있습니까?

서버 1
HT 사용 : 1
하이퍼 스레딩 비율 : 12
논리적 CPU : 24
물리적 CPU : Numa
당 2 논리적 CPU : 12
NoOfNuma : 2
MaxDop 설정은 다음과 같아야합니다. 6

서버 2
HT 사용 : 2
하이퍼 스레딩 비율 : 16
논리적 CPU : 64
물리적 CPU : 4
논리적 CPU
numa : 16 NoOfNuma : 4
MaxDop 설정은 4 여야합니다.

나는 이것이 제안 일 뿐이라는 것을 알고 있습니다. 그러나 위의 서버 (# 2)는 2 대신 4 프로세서, 물리적 CPU 당 6 코어 대신 8 코어로 구성되어 있습니다. 덜 강력한 서버의 경우 6에 비해 6에서 MAXDOP을 권장합니다.

위의 kbb 기사는 위의 8 시나리오를 제안합니다. "NUMA가 구성되고 하이퍼 스레딩이 활성화 된 서버의 경우 MAXDOP 값은 NUMA 노드 당 실제 프로세서 수를 초과하지 않아야합니다."


MAXDOP를 코어 / numa 노드 수보다 높게 설정하면 니어 메모리로의 호출로 니어 메모리로 호출하는 것보다 몇 배 더 느립니다. 각 numa 노드에는 자체 메모리가 있기 때문입니다. 쿼리가 단일 numa 모드에있는 것보다 더 많은 스레드를 사용하면 CPU로드가 여러 코어에 분산되므로 여러 개의 메모리 노드가 분산됩니다.
— Max Vernon

MAXDOP을로드를 실행하는 서버에 적합한 설정으로 설정하는 것이 좋습니다. 특정 하중에 가장 적합한 설정 만 결정할 수 있습니다. 이 게시물은 지침 일뿐입니다.
— Max Vernon

당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.