sql pass 臺灣分部十一月份聚會-take a trip down memory lane

20
SQL Server memory management past, present and hidden gem Po

Upload: sqlpasstw

Post on 27-Jan-2015

132 views

Category:

Technology


8 download

DESCRIPTION

講師:Po Chen 講師簡介:美商金融業 Senior Database Architect / Engineer 分享主題:Walking down memory lane, something about SQL Server memory 分享主題簡介: 深入淺出 SQL Server 記憶體管理 SQL Server memory management past, present and hidden gem. * Memory Concept * SQLOS and memory management * Large Page * Memory Corruption

TRANSCRIPT

Page 1: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

Take a trip down memory lane

SQL Server memory management past, present and hidden gem

Po

Page 2: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

2

Who am I ?

Carnegie Mellon University, MS in Information TechnologyBanking and Financial industry. Manage more than 4,000 database instances environment including, MSSQL, MSAS, Sybase, DB2 and Oracle. Manage the Database client application deployment to more than 100,000 desktops/Servers.Blog: http://sqlpanda.com Twitter: https://twitter.com/SQLPANDA Linkedin: http://www.linkedin.com/pub/po-chen/2/249/791

Page 3: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

Today’s Topic

SQLOS and memory managementLarge PageDatabase Corruption

… Mostly 64-bit

NUMA WOW64Column store IndexSQL Server in Virtualization environment SQL Server 2014 (Hekaton, BP extension ..)Memory pressure

What we will cover today ? What we will not cover today ?

Page 4: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane
Page 5: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

5

Why do we care about the memory?

Page 6: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

6

Memory acronym

• VAS• PAE• AWE• 3GB/USERVA• MTL• LPIM• SPA• MPA• ASPA• LPA

Virtual Address SpacePhysical Address ExtensionAddress Windowing Extensions4GB TuningMemory To LeaveLock Page In MemorySingle Page AllocationMulti-Page allocation Any Size Page AllocationLarge Page Allocation

Acronym Full Name

In-complete List

Page 7: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

7

VAS ?

Page 8: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

8

Max Memory now means Max Memory

(Almost …)

Page 9: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

9

Memory Manager Change in SQL 2012

/

• HeapAlloc• AllocateUserPhysicalPages• AllocateUserPhysicalPagesNum

a• VitrualAlloc

Page 10: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

10

Performance Counter

-Memory Manager \ Reserved MemoryMemory Manager \ Reserved Memory In UseBuffer Pool \ Target (Pages)Buffer Pool \ Committed (Pages)Buffer Pool \ Stolen (Pages) + Buffer Pool \ DatabaseBuffer Pool \ Reserved (Pages)Buffer Pool \ Free (Pages)-Buffer Pool \ Stolen Potential (Pages)

Memory Manager \ Large Pages AllocatedMemory Manager \ Emergency MemoryMemory Manager \ Emergency Memory In UseMemory Manager \ Target Committed (KB)Memory Manager \ Current Committed (KB)Memory Manager \ Pages Allocated (KB)Memory Manager \ Pages Reserved (KB)Memory Manager \ Pages Free (KB)Memory Manager \ Pages In UseMemory Manager \ Page Alloc Potential (KB)

SQL 2008R2 SQL 2012

Page 11: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

11

Memory Manager type and error log

Error Log will show the physical memory installed on the host.EX: Detected 8499 MB of RAM. This is an informational message; no user action is required. New in 2012

Conventional memory

• Default• Using

conventional memory in the memory manager.

AWE

• LPIM• “Using locked

pages in the memory manager. ” OR “Address Windowing Extensions enabled."

Large Page

• Host has RAM > 8GB

• LPIM• SQL Enterprise

Edition • “Using locked

pages in the memory manager. ” and “Large Page Allocated: 32MB”

Page 12: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

12

SQLOS

• Sqlserver.exe -> 60MB• Sqlos.dll -> 16KB

Sqlserver.exe -> 188KBSqldk.dll -> 2MBSqlos.dll -> 26KBSqlmin.dll -> 30MBSqllang.dll -> 33MB

Pre SQL Server 2012 (2008R2) SQL Server 2012

Page 13: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

13

SQLOS

Use Windows API to• Check LPIM privilege: AdjustTokenPrivileges()• Allocate the memory: VirtualAlloc()• Monitor the memory: QueryMemoryResourceNotification()

Lets do some debug : ( Windbg ) -> DO NOT do this on the production system

Page 14: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

14

LPIM & AWE

Lets do some debug : ( Windbg ) -> DO NOT do this on the production system ever!!

Page 15: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

15

LPIM & LPA

LPIM LPIM

2012: “Using locked pages in the memory manager” 2008: “Address Windowing Extensions enabled”

Host has RAM > 8GBSQL Enterprise Edition

2012: Using locked pages in the memory manager. Large Page Allocated: 32MB2008:Large Page Extensions enabled. Large Page Granularity: 2097152 Large Page Allocated: 32MB locked pages for buffer pool.

-T 834 2012: Same as before  2008:  Using large pages for buffer pool. 

DO NOT use 834 if you have column store index in SQL 2012

Page 16: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

16

Database Corruption: 823, 824, 825, 832823: Hard IO error, Can not read page at all824: Soft IO error -> Check SUM fail during the data read. 825: IO Error, Retry success 832 error -> memory Corruption Error: 832, Severity: 24, State: 1.A page that should have been constant has changed (expected checksum: <expected value>, actual checksum: <actual value>, database <dbid>, file '<filename>', page <pageno>). This usually indicates a memory failure or other hardware or OS corruption.

Application Assisted Memory Error Recovery

Page 17: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

JOIN US for our second annual event to get the best learning for analyzing, managing, and sharing business information and insights through the Microsoft Data Platform of technologies.

Page 18: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

SQLSaturday Events – Nov/DecUpcoming North America Events Upcoming International Events

• Nov 16 #265 Oregon• Dec 7 #233 Washington DC

• Nov 30 #261 Moscow• Dec 7 #259 Kharkov• Dec 7 #266 Lima• Dec 13 #264 Ancona• Dec 21 #274 Slovenia

Visit www.sqlsaturday.com to register for an event near you!

Page 19: SQL PASS 臺灣分部十一月份聚會-Take a trip down memory lane

Stay Involved! & Happy Holiday

• Sign up for a free membership today at sqlpass.org

• Linked In: Professional Association for SQL Server• Facebook: Professional Association for SQL Server Group• Twitter: @SQLPASS• The PASS Blog: sqlpass.org