SQL Server memory architecture and debugging memory Issues

Slides:



Advertisements
Similar presentations
Windows Kernel Internals User-mode Heap Manager
Advertisements

How to Detect a Memory Leak By Using System Performance Monitor in Windows 2000.
© Neeraj Suri EU-NSF ICT March 2006 Budapesti Műszaki és Gazdaságtudományi Egyetem Méréstechnika és Információs Rendszerek Tanszék Zoltán Micskei
SQL 2012 – Tabular for DBA’s By Karan Gulati (SQL BI – MCM)
Chapter 14 Chapter 14: Server Monitoring and Optimization.
11 MONITORING MICROSOFT WINDOWS SERVER 2003 Chapter 3.
Check Disk. Disk Defragmenter Using Disk Defragmenter Effectively Run Disk Defragmenter when the computer will receive the least usage. Educate users.
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
Kevin Kline, SQL Sentry Director of Engineering Services, Microsoft SQL Server MVP since 2003 Twitter, Facebook, KEKline.
 Demand Technology Software, Inc. 32-bit Virtual Memory Constraints in Windows 2000 and 2003 Mark Friedman Demand Technology 1020 Eighth Avenue South,
 Demand Technology Software, Inc. Memory Leaks Demand Technology 1020 Eighth Avenue South, Suite 6, Naples, FL phone: (941) fax: (941)
Virtual Memory Tuning   You can improve a server’s performance by optimizing the way the paging file is used   You may want to size the paging file.
Oracle Memory Configuration on Windows Server Configuring Large Memory for Oracle on 32-bit and 64-bit Windows.
Module 15: Monitoring. Overview Formulate requirements and identify resources to monitor in a database environment Types of monitoring that can be carried.
© 2011 IBM Corporation 11 April 2011 IDS Architecture.
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
SQL Server Replication By Karthick P.K Technical Lead, Microsoft SQL Server.
Windows 2000 Memory Management Computing Department, Lancaster University, UK.
Troubleshooting From the Field – Part 2 SQL DIAG & SQL NEXUS By Ahmad Osama SQL Server Geeks - Editor In Chief and Regional Mentor(Delhi & NCR)
 Demand Technology Software, Inc. 32-bit Virtual Memory Constraints in Windows: an Update Mark Friedman Demand Technology 1020 Eighth Avenue South,
Kevin Kline, SQL Sentry Director of Engineering Services, Microsoft SQL Server MVP since 2003 Twitter, Facebook, KEKline.
Key Perf considerations & bottlenecks Windows Azure VM characteristics Monitoring TroubleshootingBest practices.
Get More out of SQL Server 2012 in the Microsoft Private Cloud environment Guy BowermanMadhan Arumugam DBI208.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Copyright ®xSpring Pte Ltd, All rights reserved Versions DateVersionDescriptionAuthor May First version. Modified from Enterprise edition.NBL.
Managing and Monitoring Windows 7 Performance Lesson 8.
Agenda for Today Do Chapter 14 Final Project Review for Final.
Learningcomputer.com SQL Server 2008 – Profiling and Monitoring Tools.
© 2008 Quest Software, Inc. ALL RIGHTS RESERVED. Perfmon and Profiler 101.
1 Chapter Overview Performing Configuration Tasks Setting Up Additional Features Performing Maintenance Tasks.
SQLRX – SQL Server Administration – Tips From the Trenches SQL Server Administration – Tips From the Trenches Troubleshooting Reports of Sudden Slowdowns.
Pradeep Kumar C Support Escalation Engineer Windows Azure Diagnostics Logging and Monitoring in the Cloud.
Amit Bansal CTO | Peopleware India (unit of eDominer Systems) | |
IN-MEMORY OLTP By Manohar Punna SQL Server Geeks – Regional Mentor, Hyderabad Blogger, Speaker.
Chapter 10 System Monitoring Issues Performance Benchmarks NT Server Services Users and Server Access Information Task Manager for Applications Ram and.
ESRI User Conference 2004 ArcSDE. Some Nuggets Setup Performance Distribution Geodatabase History.
Process Architecture Process Architecture - A portion of a program that can run independently of and concurrently with other portions of the program. Some.
SQL Server Memory Architecture Sumit Sarabhai Microsoft Corp.
Troubleshooting SQL Server Performance: Tips &Tools Amit Khandelwal.
Presented by Vishy Grandhi.  Lesson 1: AX Overview  Lesson 2: Role based security  Lesson 3: Monitoring  Troubleshooting.
FINDING THE “MAKE IT FASTER!” BUTTON AND HITTING IT! Ewan MacKellar Senior Premier Field Engineer Microsoft SESSION CODE: SVR306 (c) 2011 Microsoft. All.
Module 6: Administering Reporting Services. Overview Server Administration Performance and Reliability Monitoring Database Administration Security Administration.
TOP 10 Thinks you shouldn’t do with/in your database
COMP091 – Operating Systems 1 Memory Management. Memory Management Terms Physical address –Actual address as seen by memory unit Logical address –Address.
Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer |
SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.
Configuring SQL Server for a successful SharePoint Server Deployment Haaron Gonzalez Solution Architect & Consultant Microsoft MVP SharePoint Server
9 Copyright © 2004, Oracle. All rights reserved. Getting Started with Oracle Migration Workbench.
Oracle Database Architectural Components
SQL Database Management
Monitoring SQL with System Center
Troubleshooting Tools
SharePoint Solutions Architect, Protiviti
SQL Server Internals Overview
MONITORING MICROSOFT WINDOWS SERVER 2003
Chapter Overview Understanding the Database Architecture
Dynamics AX Performance
Troubleshooting Availability Group Failovers
CS399 New Beginnings Jonathan Walpole.
Turbo-Charged Transaction Logs
Windows Processes and Services
Microsoft SQL Server 2014 for Oracle DBAs Module 2
Oracle Memory Configuration on Windows Server
Process Description and Control
Unit OS5: Memory Management
Buddy Allocation CS 161: Lecture 5 2/11/19.
Inside the Database Engine
Inside the Database Engine
Inside the Database Engine
Presentation transcript:

SQL Server memory architecture and debugging memory Issues Karthick P.K |Technical Lead | Microsoft SQL Server Support | E-mail:  karthick.krishnamurthy@microsoft.com My face book group :My Facebook |My site: Mssqlwiki.com| Twitter:@mssqlwiki www.facebook.com/SQLServerGeeks

What will you get out of this session? What is VAS. What is B-pool. What is MTL. What is PAE/USERVA. What is AWE. What is Lock pages in memory. Memory DMV’s. How SQL Server responds to memory pressure. How to debug SQL Server memory errors and lot of internals.

Address Windowing Extension Virtual Address Space 32-Bit 64-Bit PAE in windows and AWE in SQL Server 64 GB 16 EB Address Windowing Extension Unused 4 GB KERNEL MODE 1GB - 2GB KERNEL MODE 2 GB USER MODE 4GB KERNEL MODE 8 TB USER MODE 2GB – 3GB 2 TB Physical Memory Limit WOW USER MODE 2 GB USER MODE 8 TB userVA /3GB BCDEdit.exe

VAS and Memory States SQLServr.exe NOTEPAD.exe C Committed Working-Set KERNEL KERNEL CM Committed Mapped Committed Paged-Out C USER MODE ADDRESS SPACE C FREE C USER MODE ADDRESS SPACE FREE RESERVED C FREE F CM F CM CM FREE CM SQLSERVR.EXE MSVCRT. DLL NOTEPAD. EXE

What is BPOOL,MTL and how are they calculated User Mode VAS -g Memory To Leave MTL (Memory to Leave)= (Stack size * max worker threads) + Additional space (By default 256 MB and can be controlled by -g). Stack size =512 KB per thread for 32 Bit SQL Server I.e. = (256 *512 KB) + 256MB =384MB Buffer Pool BPool = Minimum (Physical memory, User address space – MTL) – BUF structures SQL Server "User address space" is broken into two regions: MemToLeave and Buffer Pool Size of MemToLeave (MTL) and Buffer Pool (BPool) is determined by SQL Server during start up as below. MTL (Memory to Leave)= (Stack size * max worker threads) + Additional space (By default 256 MB and can be controlled by -g). Stack size =512 KB per thread for 32 Bit SQL Server I.e = (256 *512 KB) + 256MB =384MB Additional space to load Dll’s= 256 MB from SQLServer2000. This space is used to store 1. COM objects 2. Extended stored procedure 3. Memory allocated by linked servers (loaded in process ) or other Dll’s loaded  in SQL Server process 4. Memory allocated by SQL Server memory manger if the allocation size in greater than 8K and need’s contiguous memory (Multiple_pages_kb). 5. SQLCLR Reference: http:\\mssqlwiki.com/sqlwiki/sql-performance/basics-of-sql-server-memory-architecture/

AWE Limited to data and index pages. What is AWE AWE Limited to data and index pages. Every page has to be mapped and un- mapped with in my bpool for access User Mode VAS -g Memory To Leave 64 GB Buffer Pool Reference: http://mssqlwiki.com/2010/11/11/awe-allocator-apis-how-sql-server-awe-works/

SQL Server [2005, 2008, 2008 R2] Memory Manager User Mode VAS -g Memory To Leave Virtual Allocator CLR Multi-Page Allocator Buffer Pool Memory Manager Memory Objects Single-Page Allocator Page Reservation Reference: http:\\mssqlwiki.com/sqlwiki/sql-performance/basics-of-sql-server-memory-architecture/

Memory Errors MemToLeave errors: SQL Server 2000 WARNING: Failed to reserve contiguous memory of Size= 65536. WARNING: Clearing procedure cache to free contiguous memory. Error: 17802 "Could not create server event thread." SQL Server could not spawn process_loginread thread. SQL Server 2005/2008 Failed Virtual Allocate Bytes: FAIL_VIRTUAL_RESERVE 122880 Buffer Pool errors: BPool::Map: no remappable address found. BufferPool out of memory condition LazyWriter: warning, no free buffers found. Either BPool (or) MemToLeave errors: Error: 17803 “Insufficient memory available..” Buffer Distribution: Stolen=7901 Free=0 Procedures=1 Inram=201842 Dirty=0 Kept=572… Error: 701, Severity: 17, State: 123. There is insufficient system memory to run this query. There is insufficient system memory in resource pool ‘default’ to run this query Reference http://mssqlwiki.com/sqlwiki/sql-performance/troubleshooting-sql-server-memory/

Demo

64-Bit memory models Conventional LOCKED PAGES LARGE PAGES

There are three types of memory model’s in 64-Bit SQL Server. Conventional : Normal physical page size (4 / 8KB),memory can be paged, dynamic. 2. Locked : Normal physical page size (4 / 8KB), Bpool can not be paged, dynamic, Requires startup account of SQL Server to have "Lock pages in memory" privilege, Memory is allocated by using Address Windowing Extensions (AWE) API’s 3. Large : Large physical page size ( > = 2MB), Non-page able, static, Memory is committed at startup,” Max server memory” is recommended, requires startup account of SQL Server to have "Lock pages in memory" privilege. Reference: http:\\mssqlwiki.com/sqlwiki/sql-performance/basics-of-sql-server-memory-architecture/

Memory calculations in 64-Bit SQL Server are straight forward. User VAS is large so no MTL. That doesn't mean we don’t allocate out side BPOOL. SQL Server calculates the size of RAM during, max server memory the startup and reserve it , minimum of (reserved space, “Max server memory”) is used as B-pool. BPOOL is capped by max server memory. When BPOOL is not capped SQL Server will grow its memory as much as possible and will not scale down its usage unless there is Low physical memory notification from windows or max server memory is reduced. When LPIM is enabled with trace flag 845 AWE allocator API’s are used for memory allocation. When AWE allocator API’s are used for memory allocation by SQL Server Windows can not trim the BPOOL of SQL Server. LPIM doesn’t protect Non Bpool from paging. Should I have LPIM? http://sqlserverscribbles.com/2013/01/04/lock-pages-in-memory-is-recommended-or-not/

Working Set Trim What is working set: Memory allocated by the process which is currently in RAM.   Committed: Total memory that is allocated by process (allocated bytes can be in RAM or Page file)  Working Set trimming (Paging):  Windows is moving the allocated bytes of the process from physical RAM to page file because of memory pressure. Memory pressure is most commonly caused by applications or windows components that are requesting more memory causing OS to start trimming working set of other processes to satisfy these new requests. When >50% SQL Servers committed memory is pages below message is logged in errorlog “A significant part of SQL Server process memory has been paged out. This may result in performance degradation. This may result in a performance degradation. Duration: 0 seconds. Working set (KB): 2007640, committed (KB): 4594040, memory utilization: 43%.” message in SQL Server error log . Pay attention to Working set , committed and memory utilization(Percentage of SQL Server memory in RAM).

How to monitor and troubleshoot working set trim? Historical data of working set trim can be captured by using ring buffer records. Performance monitor : (Process: Private bytes and Working set ) Do not use task manager or below perfmon counters when you use LPIM, they will cheat you Performance object: Process Counter: Private Bytes Instance: sqlservr Counter: Working Set you can view the Bpool usage from Performance object: SQL Server:Memory Manager Counter: Total Server Memory(KB). You can use LPIM which protect Bpool from paging after you have identified the cause. SQL Server memory usage can also be viewed from sys.dm_os_process_memory Reference : http://mssqlwiki.com/2012/06/27/a-significant-part-of-sql-server-process-memory-has-been-paged-out/

SQL Server is smart and responds to memory pressure Demo Reference: http://mssqlwiki.com/2010/12/02/creatememoryresourcenotification/

Questions?

Talk about your experience www.FaceBook.com/SQLServerGeeks Be a member – www.SQLServerGeeks.com @SQLServerGeeks Talk about your experience Post photos Blog, Tweet (#SQLServerGeeks) Post your experience on Forums Why do all this? “We want to make the community bigger & larger and we need your support”

for suggestions, please email to admin@SQLServerGeeks.com Thank you  Have a question? email to karthick@mssqlwiki.com Or Post in www.FaceBook.com/SQLServerGeeks for suggestions, please email to admin@SQLServerGeeks.com