SQL 2016 – It Just Runs Faster: Dynamic Memory Object (CMemThread) Partitioning

Published Mar 01 2022 09:14 AM 545 Views
Microsoft
Moved from: bobsql.com

 

The CMemThread waits (PWAIT_MEMTHREAD) can be a point of contention as machine sizes advance.   The CMemThread object type is utilized in 100s of objects throughout the SQL Server code base and can be partitioned globally, by node or by cpu.  

 

The vast majority of CMemThread objects leverage global partitioning.   Trace flag -T8048 only forces node based partitioning to cpu based partitioning.  Each time a highly contended, global partitioned object was encountered a hotfix was required to partition the object.

 

SQL Server 2005, 2012 and 2014 contains dynamic latch promotion and demotion logic (Super/Sub-Latch).   The concept is to watch the number of acquires on a latch along comparing sampling rates as to how long it should take to acquire a latch without contention.   When a shared latch can be promoted (partitioned) in order to improve performance and scalability SQL Server will do so.

 

Taking a page from the latch design concepts, CMemThread is designed in SQL Server 2016 to dynamically promote a contended CMemThread object.   SQL Server 2016 detects contention points on a specific CMemThread object and promotes the object to a per node or per cpu based implementation.   Once promoted the object remains promoted until the SQL Server instance is restarted.

 

The dynamic CMemThread design is a superset of -T8048 behavior, allowing you to deploy SQL Server 2016 on a wide variety of hardware environments and SQL Server 2016 automatically adjusts CMemThread behavior to the applicable load.  By partitioning contended CMemThread objects it removes the waits behaviors and allows SQL Server 2016 to scale to your applications needs.

 

The sys.dm_os_memory_objects DMV has been extended to include additional contention information which can be used to determine the promotion level along with new XEvents provided to monitor the activity.

 

‘It Just Runs Faster’ – Apply SQL Server 2016 and SQL Server dynamically partitions a CMemThread encountering contention, increasing scalability of the instance.

 

%3CLINGO-SUB%20id%3D%22lingo-sub-3236474%22%20slang%3D%22en-US%22%3ESQL%202016%20%E2%80%93%20It%20Just%20Runs%20Faster%3A%20Dynamic%20Memory%20Object%20(CMemThread)%20Partitioning%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3236474%22%20slang%3D%22en-US%22%3E%3CH6%20id%3D%22toc-hId-1792252659%22%20id%3D%22toc-hId-1792252690%22%3EMoved%20from%3A%20bobsql.com%3C%2FH6%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%20color%3D%22%23000000%22%3E%3CFONT%3EThe%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FFONT%3E%3CFONT%3E%3CA%3E%3CFONT%20face%3D%22Calibri%22%20color%3D%22%230066cc%22%3E%3CU%3ECMemThread%3C%2FU%3E%3C%2FFONT%3E%3C%2FA%3E%3C%2FFONT%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%3CFONT%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewaits%20(PWAIT_MEMTHREAD)%20can%20be%20a%20point%20of%20contention%20as%20machine%20sizes%20advance.%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3EThe%20CMemThread%20object%20type%20is%20utilized%20in%20100s%20of%20objects%20throughout%20the%20SQL%20Server%20code%20base%20and%20can%20be%20partitioned%20globally%2C%20by%20node%20or%20by%20cpu.%3C%2FFONT%3E%3CSPAN%3E%3CFONT%3E%26nbsp%3B%26nbsp%3B%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3EThe%20vast%20majority%20of%20CMemThread%20objects%20leverage%20global%20partitioning.%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3ETrace%20flag%20-T8048%20only%20forces%20node%20based%20partitioning%20to%20cpu%20based%20partitioning.%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3EEach%20time%20a%20highly%20contended%2C%20global%20partitioned%20object%20was%20encountered%20a%20hotfix%20was%20required%20to%20partition%20the%20object.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3ESQL%20Server%202005%2C%202012%20and%202014%20contains%20dynamic%20latch%20promotion%20and%20demotion%20logic%20(Super%2FSub-Latch).%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3EThe%20concept%20is%20to%20watch%20the%20number%20of%20acquires%20on%20a%20latch%20along%20comparing%20sampling%20rates%20as%20to%20how%20long%20it%20should%20take%20to%20acquire%20a%20latch%20without%20contention.%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3EWhen%20a%20shared%20latch%20can%20be%20promoted%20(partitioned)%20in%20order%20to%20improve%20performance%20and%20scalability%20SQL%20Server%20will%20do%20so.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3ETaking%20a%20page%20from%20the%20latch%20design%20concepts%2C%20CMemThread%20is%20designed%20in%20SQL%20Server%202016%20to%20dynamically%20promote%20a%20contended%20CMemThread%20object.%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3ESQL%20Server%202016%20detects%20contention%20points%20on%20a%20specific%20CMemThread%20object%20and%20promotes%20the%20object%20to%20a%20per%20node%20or%20per%20cpu%20based%20implementation.%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3EOnce%20promoted%20the%20object%20remains%20promoted%20until%20the%20SQL%20Server%20instance%20is%20restarted.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3EThe%20dynamic%20CMemThread%20design%20is%20a%20superset%20of%20-T8048%20behavior%2C%20allowing%20you%20to%20deploy%20SQL%20Server%202016%20on%20a%20wide%20variety%20of%20hardware%20environments%20and%20SQL%20Server%202016%20automatically%20adjusts%20CMemThread%20behavior%20to%20the%20applicable%20load.%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3EBy%20partitioning%20contended%20CMemThread%20objects%20it%20removes%20the%20waits%20behaviors%20and%20allows%20SQL%20Server%202016%20to%20scale%20to%20your%20applications%20needs.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%20color%3D%22%23000000%22%3E%3CFONT%3EThe%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FFONT%3E%3CFONT%3E%3CA%3E%3CFONT%20face%3D%22Calibri%22%20color%3D%22%230066cc%22%3E%3CU%3Esys.dm_os_memory_objects%3C%2FU%3E%3C%2FFONT%3E%3C%2FA%3E%3C%2FFONT%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EDMV%20has%20been%20extended%20to%20include%20additional%20contention%20information%20which%20can%20be%20used%20to%20determine%20the%20promotion%20level%20along%20with%20new%20XEvents%20provided%20to%20monitor%20the%20activity.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%26nbsp%3B%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20face%3D%22Calibri%22%3E%3CFONT%20color%3D%22%23000000%22%3E%3CSPAN%3E%3CSTRONG%3E%3CFONT%3E%E2%80%98It%20Just%20Runs%20Faster%E2%80%99%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CFONT%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%E2%80%93%20Apply%20SQL%20Server%202016%20and%20SQL%20Server%20dynamically%20partitions%20a%20CMemThread%20encountering%20contention%2C%20increasing%20scalability%20of%20the%20instance.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3236474%22%20slang%3D%22en-US%22%3E%3CH3%20class%3D%22single-title%22%20id%3D%22toc-hId-1080685008%22%3ESQL%202016%20%E2%80%93%20It%20Just%20Runs%20Faster%3A%20Dynamic%20Memory%20Object%20(CMemThread)%20Partitioning%3C%2FH3%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3236474%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBobSQL%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Mar 01 2022 09:14 AM
Updated by: