SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Memory Management in SQL Server
                        Prashant Kumar
                         http://SQLactions.com
1. Memory Manager: Windows NT
                2. Memory Manager: SQLOS




Customer Service & Support
1. Memory Manager:
           Windows NT
• Virtual memory
   o    Address Space Layout
   o    Virtual Memory Manager
   o    32-bit Virtual Addresses
   o    Address Translation
• Memory Pool
• 4GT Tuning
   o    /3GB Switch (Two slides)
   o    Effects of /3GB Tuning
   o    /USERVA Switch
• PAE
   o Using /3GB & PAE together
• AWE
• 32-bit vs 64-bit Virtual Memory
Memory Manager
• As the size of applications and the operating systems
  that run grow larger and larger, so do their demands on
  memory.
• Consequently, all modern operating systems provide a
  form of virtual memory to applications.
• Windows Server 2003 onwards, the applications ported
  to it, eventually require even more memory than they
  did on the last operating system on which they ran.
• Even applications being written exclusively for Windows
  NT will be written with the future in mind and will no
  doubt take advantage of all the memory that is
  available to them.
Virtual Memory
•   Address Space Layout
•   Virtual-Memory Manager (VMM)
•   32-bit Virtual Addresses
•   Address Translation
Address Space Layout
•   Windows provides a page-based virtual memory management
    scheme that allows applications to realize a 32-bit linear address
    space for 4 GB of memory.
•   Each application can address 2 GB of available memory, regardless
    of how much physical memory actually exists.
•   Windows employs the PC's hard disk as the memory-backing store,
    and has a practical limit imposed only by the available disk space.
Virtual Memory Manager
•   Enables Windows to provide virtually unlimited memory to the system.
•   Is constructed upon a page-based memory management scheme that
    divides all of memory into equal chunks called pages.
•   Each page is 4096 bytes (4 KB) in size with no discrimination applied as to
    how a page is used.
•   Everything in Windows—code, data, resources, files, and dynamic
    memory—is implemented using pages of physical memory.
•   Employs the hard disk to store unutilized pages of memory in one or more
    files called pagefiles.
•   Pagefiles represent pages of data that are not currently being used, but
    may be needed spontaneously at any time.
•   Pagefiles in Windows are dynamic in size, allowing them to grow as the
    demands for pages of memory grow.
•   Is able to make pages of memory available to applications on demand
    by swapping pages to and from pagefiles.
•   Provides much more virtual memory than the available physical memory.
32-bit Virtual Addresses
• Windows implement a virtual memory system based
  on a flat (linear) 32-bit address space.
   o 32 bits of address space translates into 4 GB of virtual memory.
• To Windows, the 32-bit virtual address is nothing more
  than a placeholder of information used to find the
  actual physical address.
   o Windows separates each 32-bit virtual address into three groups:
• Two containing 10 bits and one containing 12 bits.
   o Each group of bits is then used independently as an offset into a specific
     page of memory.
Address Translation
          •   User applications reference
              32-bit virtual addresses.
          •   Using data structures that the
              memory manager creates
              and maintains, the CPU
              translates virtual addresses
              into physical addresses.
          •   Virtual addresses are not
              mapped directly to physical
              ones.
          •   Instead, each virtual address
              is associated with a system-
              space structure called a
              page table entry (PTE), which
              contains the physical address
              to which the virtual one is
              mapped.
Memory Pools
      • Paged Pool
         o   Is a region of virtual memory in
             system space that can be paged in
             and out of the system.
         o   Is accessible from any process
             context.
         o   Device drivers that do not need to
             access the memory from
             DPC/dispatch level or above can
             use paged pool.
      • Nonpaged Pool
         o   Consists of ranges of system virtual
             addresses that are guaranteed to
             reside in physical memory at all
             times.
         o   Can be accessed at any time (from
             any IRQL level and from any
             process context) without incurring a
             page fault.
         o   Page faults cannot be satisfied at
             DPC/dispatch level or above.
4GT Tuning
• Operating systems based on Windows NT
  technology provide applications with a 4 GB virtual
  address space.
• The virtual address space is divided such that 2 GB is
  available to the application and the other 2 GB is
  available only to the system.
• The 4GT RAM Tuning feature:
   o Increases the user-mode memory available to the application to 3 GB.
   o Reduces the amount available to the system to 1 GB.

• The 4GB Tuning feature is enabled by adding /3GB
  Switch to the Boot.ini file.
/3GB Switch
• /3GB is a switch used within the Boot.ini to:
   o Increase the size of a user process address space from 2 GB to 3GB.
   o Reduce the Kernel space from 2 GB to 1 GB.

• The application .exe must be flagged as a 3-GB-
  aware application.
/3GB Switch
Effects of /3GB Tuning
• When you use the /3GB switch, the available
  address space is reduced to only 1 GB of operating
  system space.
• This 1 GB is reserved to load the operating system
  kernel mode modules, all the page table entries,
  and the pools.
• As a result, the operating system will have only a
  fraction of kernel address space to store PTEs, Pool
  Memory and System Cache.
• This could cause potential performance issues for
  any kernel-mode component.
/USERVA Switch
       •   Windows 2003 Servers and
           Windows XP SP1 onwards, a
           new switch /USERVA was
           incorporated to work in
           conjunction with the /3GB
           switch.
       •   You can use the /USERVA
           switch for more precise tuning
           of user and kernel virtual
           memory space in the
           Windows Server 2003 family.
       •   The use of the /USERVA switch
           with the /3GB switch in the
           Boot.ini file helps tune the
           user-mode space to a value
           between 2 GB and 3 GB.
       •   The difference is given back
           to the kernel mode.
Summary of 4GT Tuning
•   4GT allows memory intensive Win32 applications to increase its virtual address space beyond
    2GB
      o Causes kernel virtual address space to be reduced to 1GB
•   This feature is enabled by
      o On pre-Vista OSs use /3GB switch in boot.ini
             • If PAE mode is enabled, access to RAM is limited to 16GB
      o On Vista and later OSs use “bcdedit/set IncreaseUserVa3072”
             • If PAE mode is enabled, all of 64GB of RAM is accessible
•   Only applications linked with /LARGEADDRESSAWARE flag can use this extra virtual address
    space
      o All other applications can only use 2GB
•   /USERVA enables fine tuning of UVAS between 2GB and 3GB
      o Used in tandem with the /3GB switch
•   Reduces the following kernel virtual address ranges
      o Maximum Paged Pool to 256MB
      o Maximum Non-Pages Pool to 128MB
•   Supported on the following Windows 2003 Server version of the OS
      o Standard Edition, Enterprise Edition, DataCenterEdition
Physical Address Extension (PAE)
                • Physical Address
                  Extension (PAE) allows
                  up to 64 GB of physical
                  memory.
                • PAE maps up to 64 GB
                  of memory into a 32-bit
                  (4 GB) virtual address
                  space.
                • PAE is supported in:
                   o Windows XP Professional
                   o Windows 2000 Advanced
                     Server and Datacenter Server
                   o Windows Server 2003, Enterprise
                     Edition and Datacenter Edition.
Using /3GB & /PAE
            Together
• Using /3GB and/or /PAE changes the amount of
  resources that are dedicated for various operations.
   o Using /3GB reduces the amount of nonpaged pool from 256MB to 128MB.

• Using /3GB and /PAE together:
   o Provides some customers the most optimum performance for their servers.
   o Is required when using applications such as Exchange Server.
Address Windowing Extensions (AWE)
                 • Is a set of APIs that allows an
                   application to quickly
                   manipulate physical
                   memory greater than 4GB.
                 • Allows applications to
                   directly address huge
                   amounts of memory while
                   continuing to use 32-bit
                   pointers.
                 • Allows applications to have
                   data caches larger than
                   4GB.
                 • Uses physical nonpaged
                   memory and window views
                   of various portions of this
                   physical memory within a
                   32-bit virtual address space.
32-bit vs. 64-bit Virtual
        Memory
2. Memory Manager: SQLOS

•   NUMA (Non-Uniform Memory Architecture)
•   BP and MTL ?
•   Memory Types
•   Memory Pressure
SQLOS
• Memory Management
• Scheduling
• Exception handling
Protocols

                                             Query Processor
                                                                     Database           Query
                Parser         Optimizer     SQL Manager
SQLOS API




                                                                     Manager           Executor
              Transaction Services                                                  Access Methods

              Lock Manager
                                              Storage Engine                          Managers for:
                                                                                  Row Operations




                                                                                                                      External Components (CLR/MDAC)
                                                                                  Indexes
              File Manager                              Utilities:                Pages
                                              Bulk Load DBCC                      Allocations
              Buffer Manager                  Backup/Restore                      Versions


                                                SQLOS API

            Deadlock




                                                                                                  SQLOS Hosting API
                                                                         Lock
            Monitor
                                                                        Manager
            Resource                       SQLOS                                       I/O
            Monitor                                         Synchronization
                          Buffer
             Lazy          Pool
             Writer                                  Scheduling
            Scheduler
                                            Memory Manager
             Monitor


               = thread
“External” Components
• Three external components in SQL address space
   o Linked servers
   o COM objects (sp_OA*)
   o Extended stored procs

• Linked Server and COM objects always use
  MemToLeave. Xprocs may use either BP or MTL
  depending upon the call to srv_alloc()
Memory Access)



           Memory                          Memory


     Local                                         Local
   Memory                                        Memory
   Access                                         Access
CPU 0   CPU 1   CPU 2   CPU 3   CPU …   CPU …   CPU … CPU n
Non-Uniform Memory
    Architecture (NUMA)
• Reduces load on memory placed by multiple high speed
  CPUs
• Groups of CPUs organized into nodes
• Nodes have local memory, cache and I/O controllers
• Accessing memory in other nodes involves higher latency
• NUMA Ratio is ratio of local vs. remote memory access time
• Cache Coherency maintained by hardware
• BIOS Static Affinity Resource Table (SART) table describes
  NUMA layout to Windows
• OS support for NUMA
• Schedules threads within same process on CPUs local to a
  node
• Memory allocation requests from local node
What is Soft-NUMA
• Activates custom NUMA configuration on
  top of any of hardware

• Registry settings control final SoftNUMA
  configuration

• Provides greater performance, scalability,
  and manageability on SMP as well as on
  real NUMA hardware
Soft-NUMA Configuration Example
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL
Server90NodeConfigurationNode0]
"CPUMask"=dword:0000000F
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL
Server90NodeConfigurationNode1]
"CPUMask"=dword:00000030
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL
Server90NodeConfigurationNode2]
"CPUMask"=dword:000000C0


[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL
ServerMSSQL.1MSSQLServerSuperSocketNetLibTcpIPAll]
"TcpPort"="1433[0x3],2000[0x4]"
"TcpDynamicPorts"=""
"DisplayName"="Any IP Address"
BufferPool and MTL?
• How is Buffer Pool size calculated?
• What happens to the rest of the VAS?
• Roughly:
       MTL = (MaxWorkerThreads * StackSize) +
DefautReservationSize
     Bpool = Min(max server memory,Min(RAM,(VAS-MTL)))
Memory Types
• Internal Virtual Memory (VAS)
• External Virtual Memory(physical RAM +Swap)
• Internal Physical Memory(Memory Used by the
  application)
• External Physical memory (PhysicalRAM)
Memory Pressure
•   Internal VAS Pressure
•   External VAS Pressure
•   Internal Physical Memory Pressure
•   External Physical memory Pressure
Internal Virtual Memory
         Pressure
• Running low on VAS due to fragmentation (a lot of
  VAS is available but in small blocks) and/or
  consumption (direct allocations, DLLs loaded in
  SQL Server VAS, high number of threads).
• SQL Server detects this condition and may release
  reserved regions of VAS, reduce buffer pool commit
  target, and start shrinking caches.
Internal Virtual Memory
         Pressure
Troubleshooting
• Identify major memory consumers inside SQL Server.
• Verify server configuration.
• Further actions depend on the investigation: check
   for workload; possible design issues; other resource
   bottlenecks.
External Virtual Memory
         Pressure
• Running low on space in the system page file(s). This
  may cause the system to fail memory allocations, as
  it is unable to page out currently allocated
  memory. This condition may result in the whole
  system responding very slowly or even bring it to a
  halt.
External Virtual Memory
            Pressure
Troubleshooting

•   Increase swap file size.
•   Check for major physical memory consumers
•   Find major system memory consumers.
•   Attempt to eliminate (if possible).
Internal Physical Memory
          Pressure
• SQL Server detects high memory consumption
  internally, causing redistribution of memory between
  internal components.

• Internal memory pressure may be a result of:

      • Responding to the external memory pressure (SQL Server sets
        lower memory usage caps).

      • Changed memory settings (e.g. ‘max server memory’).


• Changes in memory distribution of internal
  components (due to high percentage of reserved
  and stolen pages from the buffer pool).
Internal Physical Memory
         Pressure
Troubleshooting

• Identify major memory consumers inside SQL Server.
• Verify server configuration.
• Further actions depend on the investigation: check
  for workload; possible design issues; other resource
  bottlenecks
External Physical Memory
         Pressure
• Physical memory (RAM) running low. This causes the
  system to trim working sets of currently running
  processes, which may result in overall slowdown.



• SQL Server detects this condition and, depending
  on the configuration, may reduce the commit
  target of the buffer pool and start clearing internal
  caches.
External Physical Memory
         Pressure
Troubleshooting

• Find major system memory consumers.
• Attempt to eliminate (if possible).
• Check for adequate system RAM and consider
  adding more RAM
Resources
• Blogs
  o   http://blogs.msdn.com/slavao
  o   http://blogs.msdn.com/psssql/archive/2007/10/18/do-i-have-to-assign-the-lock-privilege-for-local-
      system.aspx
  o   http://blogs.msdn.com/slavao/archive/2005/02/19/376714.aspx
  o   http://blogs.msdn.com/slavao/archive/2005/08/18/453354.aspx
  o   http://blogs.msdn.com/slavao/articles/441058.aspx
  o   http://blogs.msdn.com/sqlprogrammability/



• External Links:
  o   http://lse.sourceforge.net/numa/faq
  o   http://www.modhul.com/2007/11/10/optimising-system-memory-for-sql-server-part-i/
  o   http://sqlserver.ro/blogs/cristians_blog/archive/2007/10/02/the-return-of-the-ring-buffers.aspx
  o   http://lse.sourceforge.net/numa/faq/system_descriptions.html
  o   http://lse.sourceforge.net/numa/faq/

• Books:
  o   Eldad Eilam: Reversing: Secrets of Reverse Engineering
  o   Ken Henderson: SQL Server 2005 Practical Troubleshooting The Database Engine
  o   Kalen Delaney: Inside Microsoft SQL Server 2005 The Storage Engine

• KBAs:
  o   http://support.microsoft.com/kb/918483
  o   http://support.microsoft.com//kb/271624
  o   http://support.microsoft.com//kb/907877
?
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

분석가를 위한 Aws 기반의 digital 플랫폼 구축
분석가를 위한 Aws 기반의 digital 플랫폼 구축분석가를 위한 Aws 기반의 digital 플랫폼 구축
분석가를 위한 Aws 기반의 digital 플랫폼 구축Nak Joo Kwon
 
Apache solr教學介紹 20150501
Apache solr教學介紹 20150501Apache solr教學介紹 20150501
Apache solr教學介紹 20150501Yung-Ting Chen
 
NoSQL databases - An introduction
NoSQL databases - An introductionNoSQL databases - An introduction
NoSQL databases - An introductionPooyan Mehrparvar
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQLPostgreSQL-Consulting
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQLRTigger
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMike Dirolf
 
SQL Server Versions & Migration Paths
SQL Server Versions & Migration PathsSQL Server Versions & Migration Paths
SQL Server Versions & Migration PathsJeannette Browning
 
Oracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuningOracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuningSmitha Padmanabhan
 
Object database standards, languages and design
Object database standards, languages and designObject database standards, languages and design
Object database standards, languages and designDabbal Singh Mahara
 
SQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesSQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesOsama Jomaa
 
SSAS, MDX , Cube understanding, Browsing and Tools information
SSAS, MDX , Cube understanding, Browsing and Tools information SSAS, MDX , Cube understanding, Browsing and Tools information
SSAS, MDX , Cube understanding, Browsing and Tools information Vishal Pawar
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabaseTung Nguyen Thanh
 
From distributed caches to in-memory data grids
From distributed caches to in-memory data gridsFrom distributed caches to in-memory data grids
From distributed caches to in-memory data gridsMax Alexejev
 

Was ist angesagt? (20)

Sql server basics
Sql server basicsSql server basics
Sql server basics
 
Sql server basics
Sql server basicsSql server basics
Sql server basics
 
분석가를 위한 Aws 기반의 digital 플랫폼 구축
분석가를 위한 Aws 기반의 digital 플랫폼 구축분석가를 위한 Aws 기반의 digital 플랫폼 구축
분석가를 위한 Aws 기반의 digital 플랫폼 구축
 
Apache solr教學介紹 20150501
Apache solr教學介紹 20150501Apache solr教學介紹 20150501
Apache solr教學介紹 20150501
 
NoSQL databases - An introduction
NoSQL databases - An introductionNoSQL databases - An introduction
NoSQL databases - An introduction
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL
 
NoSql
NoSqlNoSql
NoSql
 
Sql vs NoSQL
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQL
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
SQL Server Versions & Migration Paths
SQL Server Versions & Migration PathsSQL Server Versions & Migration Paths
SQL Server Versions & Migration Paths
 
Oracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuningOracle SQL, PL/SQL Performance tuning
Oracle SQL, PL/SQL Performance tuning
 
Object database standards, languages and design
Object database standards, languages and designObject database standards, languages and design
Object database standards, languages and design
 
SQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesSQL vs. NoSQL Databases
SQL vs. NoSQL Databases
 
Lecture2 oracle ppt
Lecture2 oracle pptLecture2 oracle ppt
Lecture2 oracle ppt
 
Mongodb vs mysql
Mongodb vs mysqlMongodb vs mysql
Mongodb vs mysql
 
Dbms Useful PPT
Dbms Useful PPTDbms Useful PPT
Dbms Useful PPT
 
SSAS, MDX , Cube understanding, Browsing and Tools information
SSAS, MDX , Cube understanding, Browsing and Tools information SSAS, MDX , Cube understanding, Browsing and Tools information
SSAS, MDX , Cube understanding, Browsing and Tools information
 
Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL Database
 
Indexes in postgres
Indexes in postgresIndexes in postgres
Indexes in postgres
 
From distributed caches to in-memory data grids
From distributed caches to in-memory data gridsFrom distributed caches to in-memory data grids
From distributed caches to in-memory data grids
 

Andere mochten auch

Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architectureAjeet Singh
 
Microsoft SQL Server internals & architecture
Microsoft SQL Server internals & architectureMicrosoft SQL Server internals & architecture
Microsoft SQL Server internals & architectureKevin Kline
 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsDataminingTools Inc
 
Hierarchical Storage Management
Hierarchical Storage ManagementHierarchical Storage Management
Hierarchical Storage ManagementJaydeep Patel
 
Sql architecture
Sql architectureSql architecture
Sql architecturerchakra
 
Ch 5 O O Data Modeling Class
Ch 5  O O  Data Modeling ClassCh 5  O O  Data Modeling Class
Ch 5 O O Data Modeling Classguest8fdbdd
 
Sql Server 2014 In Memory
Sql Server 2014 In MemorySql Server 2014 In Memory
Sql Server 2014 In MemoryRavi Okade
 
Microsoft sql server architecture
Microsoft sql server architectureMicrosoft sql server architecture
Microsoft sql server architectureNaveen Boda
 
Operating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management ConceptsOperating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management ConceptsPeter Tröger
 
Memory Management in Windows 7
Memory Management in Windows 7Memory Management in Windows 7
Memory Management in Windows 7Naveed Qadri
 
Windows memory management
Windows memory managementWindows memory management
Windows memory managementTech_MX
 

Andere mochten auch (16)

Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architecture
 
Microsoft SQL Server internals & architecture
Microsoft SQL Server internals & architectureMicrosoft SQL Server internals & architecture
Microsoft SQL Server internals & architecture
 
SQL 2005 Memory Module
SQL 2005 Memory ModuleSQL 2005 Memory Module
SQL 2005 Memory Module
 
Sql Server Basics
Sql Server BasicsSql Server Basics
Sql Server Basics
 
MS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database ConceptsMS Sql Server: Introduction To Database Concepts
MS Sql Server: Introduction To Database Concepts
 
Hierarchical Storage Management
Hierarchical Storage ManagementHierarchical Storage Management
Hierarchical Storage Management
 
Sql server infernals
Sql server infernalsSql server infernals
Sql server infernals
 
Sql architecture
Sql architectureSql architecture
Sql architecture
 
Ch 5 O O Data Modeling Class
Ch 5  O O  Data Modeling ClassCh 5  O O  Data Modeling Class
Ch 5 O O Data Modeling Class
 
Sql Server 2014 In Memory
Sql Server 2014 In MemorySql Server 2014 In Memory
Sql Server 2014 In Memory
 
Microsoft sql server architecture
Microsoft sql server architectureMicrosoft sql server architecture
Microsoft sql server architecture
 
Operating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management ConceptsOperating Systems 1 (9/12) - Memory Management Concepts
Operating Systems 1 (9/12) - Memory Management Concepts
 
Memory Management in Windows 7
Memory Management in Windows 7Memory Management in Windows 7
Memory Management in Windows 7
 
Windows memory management
Windows memory managementWindows memory management
Windows memory management
 
Sql Server 2012
Sql Server 2012Sql Server 2012
Sql Server 2012
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 

Ähnlich wie Memory management in sql server

CSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxCSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxMadhuraK13
 
Lecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptxLecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptxAmanuelmergia
 
Sql server 2005 memory internal
Sql server 2005 memory internalSql server 2005 memory internal
Sql server 2005 memory internalshuwutong
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadMarius Adrian Popa
 
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdfSHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdfssuser9f7ea5
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryShivam Mitra
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsDrishti Bhalla
 
Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014marvin herrera
 
UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...
UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...
UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...LeahRachael
 

Ähnlich wie Memory management in sql server (20)

CSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptxCSE2010- Module 4 V1.pptx
CSE2010- Module 4 V1.pptx
 
Operating system
Operating systemOperating system
Operating system
 
Lecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptxLecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptx
 
Os4
Os4Os4
Os4
 
Os4
Os4Os4
Os4
 
Os
OsOs
Os
 
Memory Management.pdf
Memory Management.pdfMemory Management.pdf
Memory Management.pdf
 
Ch8 main memory
Ch8   main memoryCh8   main memory
Ch8 main memory
 
Sql server 2005 memory internal
Sql server 2005 memory internalSql server 2005 memory internal
Sql server 2005 memory internal
 
Tuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy WorkloadTuning Linux Windows and Firebird for Heavy Workload
Tuning Linux Windows and Firebird for Heavy Workload
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
kerch04.ppt
kerch04.pptkerch04.ppt
kerch04.ppt
 
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdfSHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
SHARE Virtual Flash Memory VFM VSM_04-17-19.pdf
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memory
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating Systems
 
Virtual memory 20070222-en
Virtual memory 20070222-enVirtual memory 20070222-en
Virtual memory 20070222-en
 
Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014Colvin exadata mistakes_ioug_2014
Colvin exadata mistakes_ioug_2014
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...
UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...
UNIT 3-EXPLAINING THE MEMORY MANAGEMENT LOGICAL AND AND PHYSICAL DATA FLOW DI...
 

Kürzlich hochgeladen

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Memory management in sql server

  • 1. Memory Management in SQL Server Prashant Kumar http://SQLactions.com
  • 2. 1. Memory Manager: Windows NT 2. Memory Manager: SQLOS Customer Service & Support
  • 3. 1. Memory Manager: Windows NT • Virtual memory o Address Space Layout o Virtual Memory Manager o 32-bit Virtual Addresses o Address Translation • Memory Pool • 4GT Tuning o /3GB Switch (Two slides) o Effects of /3GB Tuning o /USERVA Switch • PAE o Using /3GB & PAE together • AWE • 32-bit vs 64-bit Virtual Memory
  • 4. Memory Manager • As the size of applications and the operating systems that run grow larger and larger, so do their demands on memory. • Consequently, all modern operating systems provide a form of virtual memory to applications. • Windows Server 2003 onwards, the applications ported to it, eventually require even more memory than they did on the last operating system on which they ran. • Even applications being written exclusively for Windows NT will be written with the future in mind and will no doubt take advantage of all the memory that is available to them.
  • 5. Virtual Memory • Address Space Layout • Virtual-Memory Manager (VMM) • 32-bit Virtual Addresses • Address Translation
  • 6. Address Space Layout • Windows provides a page-based virtual memory management scheme that allows applications to realize a 32-bit linear address space for 4 GB of memory. • Each application can address 2 GB of available memory, regardless of how much physical memory actually exists. • Windows employs the PC's hard disk as the memory-backing store, and has a practical limit imposed only by the available disk space.
  • 7. Virtual Memory Manager • Enables Windows to provide virtually unlimited memory to the system. • Is constructed upon a page-based memory management scheme that divides all of memory into equal chunks called pages. • Each page is 4096 bytes (4 KB) in size with no discrimination applied as to how a page is used. • Everything in Windows—code, data, resources, files, and dynamic memory—is implemented using pages of physical memory. • Employs the hard disk to store unutilized pages of memory in one or more files called pagefiles. • Pagefiles represent pages of data that are not currently being used, but may be needed spontaneously at any time. • Pagefiles in Windows are dynamic in size, allowing them to grow as the demands for pages of memory grow. • Is able to make pages of memory available to applications on demand by swapping pages to and from pagefiles. • Provides much more virtual memory than the available physical memory.
  • 8. 32-bit Virtual Addresses • Windows implement a virtual memory system based on a flat (linear) 32-bit address space. o 32 bits of address space translates into 4 GB of virtual memory. • To Windows, the 32-bit virtual address is nothing more than a placeholder of information used to find the actual physical address. o Windows separates each 32-bit virtual address into three groups: • Two containing 10 bits and one containing 12 bits. o Each group of bits is then used independently as an offset into a specific page of memory.
  • 9. Address Translation • User applications reference 32-bit virtual addresses. • Using data structures that the memory manager creates and maintains, the CPU translates virtual addresses into physical addresses. • Virtual addresses are not mapped directly to physical ones. • Instead, each virtual address is associated with a system- space structure called a page table entry (PTE), which contains the physical address to which the virtual one is mapped.
  • 10. Memory Pools • Paged Pool o Is a region of virtual memory in system space that can be paged in and out of the system. o Is accessible from any process context. o Device drivers that do not need to access the memory from DPC/dispatch level or above can use paged pool. • Nonpaged Pool o Consists of ranges of system virtual addresses that are guaranteed to reside in physical memory at all times. o Can be accessed at any time (from any IRQL level and from any process context) without incurring a page fault. o Page faults cannot be satisfied at DPC/dispatch level or above.
  • 11. 4GT Tuning • Operating systems based on Windows NT technology provide applications with a 4 GB virtual address space. • The virtual address space is divided such that 2 GB is available to the application and the other 2 GB is available only to the system. • The 4GT RAM Tuning feature: o Increases the user-mode memory available to the application to 3 GB. o Reduces the amount available to the system to 1 GB. • The 4GB Tuning feature is enabled by adding /3GB Switch to the Boot.ini file.
  • 12. /3GB Switch • /3GB is a switch used within the Boot.ini to: o Increase the size of a user process address space from 2 GB to 3GB. o Reduce the Kernel space from 2 GB to 1 GB. • The application .exe must be flagged as a 3-GB- aware application.
  • 14. Effects of /3GB Tuning • When you use the /3GB switch, the available address space is reduced to only 1 GB of operating system space. • This 1 GB is reserved to load the operating system kernel mode modules, all the page table entries, and the pools. • As a result, the operating system will have only a fraction of kernel address space to store PTEs, Pool Memory and System Cache. • This could cause potential performance issues for any kernel-mode component.
  • 15. /USERVA Switch • Windows 2003 Servers and Windows XP SP1 onwards, a new switch /USERVA was incorporated to work in conjunction with the /3GB switch. • You can use the /USERVA switch for more precise tuning of user and kernel virtual memory space in the Windows Server 2003 family. • The use of the /USERVA switch with the /3GB switch in the Boot.ini file helps tune the user-mode space to a value between 2 GB and 3 GB. • The difference is given back to the kernel mode.
  • 16.
  • 17. Summary of 4GT Tuning • 4GT allows memory intensive Win32 applications to increase its virtual address space beyond 2GB o Causes kernel virtual address space to be reduced to 1GB • This feature is enabled by o On pre-Vista OSs use /3GB switch in boot.ini • If PAE mode is enabled, access to RAM is limited to 16GB o On Vista and later OSs use “bcdedit/set IncreaseUserVa3072” • If PAE mode is enabled, all of 64GB of RAM is accessible • Only applications linked with /LARGEADDRESSAWARE flag can use this extra virtual address space o All other applications can only use 2GB • /USERVA enables fine tuning of UVAS between 2GB and 3GB o Used in tandem with the /3GB switch • Reduces the following kernel virtual address ranges o Maximum Paged Pool to 256MB o Maximum Non-Pages Pool to 128MB • Supported on the following Windows 2003 Server version of the OS o Standard Edition, Enterprise Edition, DataCenterEdition
  • 18. Physical Address Extension (PAE) • Physical Address Extension (PAE) allows up to 64 GB of physical memory. • PAE maps up to 64 GB of memory into a 32-bit (4 GB) virtual address space. • PAE is supported in: o Windows XP Professional o Windows 2000 Advanced Server and Datacenter Server o Windows Server 2003, Enterprise Edition and Datacenter Edition.
  • 19. Using /3GB & /PAE Together • Using /3GB and/or /PAE changes the amount of resources that are dedicated for various operations. o Using /3GB reduces the amount of nonpaged pool from 256MB to 128MB. • Using /3GB and /PAE together: o Provides some customers the most optimum performance for their servers. o Is required when using applications such as Exchange Server.
  • 20. Address Windowing Extensions (AWE) • Is a set of APIs that allows an application to quickly manipulate physical memory greater than 4GB. • Allows applications to directly address huge amounts of memory while continuing to use 32-bit pointers. • Allows applications to have data caches larger than 4GB. • Uses physical nonpaged memory and window views of various portions of this physical memory within a 32-bit virtual address space.
  • 21. 32-bit vs. 64-bit Virtual Memory
  • 22. 2. Memory Manager: SQLOS • NUMA (Non-Uniform Memory Architecture) • BP and MTL ? • Memory Types • Memory Pressure
  • 23. SQLOS • Memory Management • Scheduling • Exception handling
  • 24. Protocols Query Processor Database Query Parser Optimizer SQL Manager SQLOS API Manager Executor Transaction Services Access Methods Lock Manager Storage Engine Managers for: Row Operations External Components (CLR/MDAC) Indexes File Manager Utilities: Pages Bulk Load DBCC Allocations Buffer Manager Backup/Restore Versions SQLOS API Deadlock SQLOS Hosting API Lock Monitor Manager Resource SQLOS I/O Monitor Synchronization Buffer Lazy Pool Writer Scheduling Scheduler Memory Manager Monitor = thread
  • 25. “External” Components • Three external components in SQL address space o Linked servers o COM objects (sp_OA*) o Extended stored procs • Linked Server and COM objects always use MemToLeave. Xprocs may use either BP or MTL depending upon the call to srv_alloc()
  • 26. Memory Access) Memory Memory Local Local Memory Memory Access Access CPU 0 CPU 1 CPU 2 CPU 3 CPU … CPU … CPU … CPU n
  • 27. Non-Uniform Memory Architecture (NUMA) • Reduces load on memory placed by multiple high speed CPUs • Groups of CPUs organized into nodes • Nodes have local memory, cache and I/O controllers • Accessing memory in other nodes involves higher latency • NUMA Ratio is ratio of local vs. remote memory access time • Cache Coherency maintained by hardware • BIOS Static Affinity Resource Table (SART) table describes NUMA layout to Windows • OS support for NUMA • Schedules threads within same process on CPUs local to a node • Memory allocation requests from local node
  • 28. What is Soft-NUMA • Activates custom NUMA configuration on top of any of hardware • Registry settings control final SoftNUMA configuration • Provides greater performance, scalability, and manageability on SMP as well as on real NUMA hardware
  • 29. Soft-NUMA Configuration Example [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server90NodeConfigurationNode0] "CPUMask"=dword:0000000F [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server90NodeConfigurationNode1] "CPUMask"=dword:00000030 [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL Server90NodeConfigurationNode2] "CPUMask"=dword:000000C0 [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerMSSQL.1MSSQLServerSuperSocketNetLibTcpIPAll] "TcpPort"="1433[0x3],2000[0x4]" "TcpDynamicPorts"="" "DisplayName"="Any IP Address"
  • 30. BufferPool and MTL? • How is Buffer Pool size calculated? • What happens to the rest of the VAS? • Roughly: MTL = (MaxWorkerThreads * StackSize) + DefautReservationSize Bpool = Min(max server memory,Min(RAM,(VAS-MTL)))
  • 31. Memory Types • Internal Virtual Memory (VAS) • External Virtual Memory(physical RAM +Swap) • Internal Physical Memory(Memory Used by the application) • External Physical memory (PhysicalRAM)
  • 32. Memory Pressure • Internal VAS Pressure • External VAS Pressure • Internal Physical Memory Pressure • External Physical memory Pressure
  • 33. Internal Virtual Memory Pressure • Running low on VAS due to fragmentation (a lot of VAS is available but in small blocks) and/or consumption (direct allocations, DLLs loaded in SQL Server VAS, high number of threads). • SQL Server detects this condition and may release reserved regions of VAS, reduce buffer pool commit target, and start shrinking caches.
  • 34. Internal Virtual Memory Pressure Troubleshooting • Identify major memory consumers inside SQL Server. • Verify server configuration. • Further actions depend on the investigation: check for workload; possible design issues; other resource bottlenecks.
  • 35. External Virtual Memory Pressure • Running low on space in the system page file(s). This may cause the system to fail memory allocations, as it is unable to page out currently allocated memory. This condition may result in the whole system responding very slowly or even bring it to a halt.
  • 36.
  • 37. External Virtual Memory Pressure Troubleshooting • Increase swap file size. • Check for major physical memory consumers • Find major system memory consumers. • Attempt to eliminate (if possible).
  • 38. Internal Physical Memory Pressure • SQL Server detects high memory consumption internally, causing redistribution of memory between internal components. • Internal memory pressure may be a result of: • Responding to the external memory pressure (SQL Server sets lower memory usage caps). • Changed memory settings (e.g. ‘max server memory’). • Changes in memory distribution of internal components (due to high percentage of reserved and stolen pages from the buffer pool).
  • 39. Internal Physical Memory Pressure Troubleshooting • Identify major memory consumers inside SQL Server. • Verify server configuration. • Further actions depend on the investigation: check for workload; possible design issues; other resource bottlenecks
  • 40. External Physical Memory Pressure • Physical memory (RAM) running low. This causes the system to trim working sets of currently running processes, which may result in overall slowdown. • SQL Server detects this condition and, depending on the configuration, may reduce the commit target of the buffer pool and start clearing internal caches.
  • 41. External Physical Memory Pressure Troubleshooting • Find major system memory consumers. • Attempt to eliminate (if possible). • Check for adequate system RAM and consider adding more RAM
  • 42. Resources • Blogs o http://blogs.msdn.com/slavao o http://blogs.msdn.com/psssql/archive/2007/10/18/do-i-have-to-assign-the-lock-privilege-for-local- system.aspx o http://blogs.msdn.com/slavao/archive/2005/02/19/376714.aspx o http://blogs.msdn.com/slavao/archive/2005/08/18/453354.aspx o http://blogs.msdn.com/slavao/articles/441058.aspx o http://blogs.msdn.com/sqlprogrammability/ • External Links: o http://lse.sourceforge.net/numa/faq o http://www.modhul.com/2007/11/10/optimising-system-memory-for-sql-server-part-i/ o http://sqlserver.ro/blogs/cristians_blog/archive/2007/10/02/the-return-of-the-ring-buffers.aspx o http://lse.sourceforge.net/numa/faq/system_descriptions.html o http://lse.sourceforge.net/numa/faq/ • Books: o Eldad Eilam: Reversing: Secrets of Reverse Engineering o Ken Henderson: SQL Server 2005 Practical Troubleshooting The Database Engine o Kalen Delaney: Inside Microsoft SQL Server 2005 The Storage Engine • KBAs: o http://support.microsoft.com/kb/918483 o http://support.microsoft.com//kb/271624 o http://support.microsoft.com//kb/907877
  • 43. ?

Hinweis der Redaktion

  1. On startup, Database Engine writes the node information to the error log. To determine the node number of the node you want to use, either read the node information from the error log, or from the sys.dm_os_schedulers view.select * from sys.dm_os_schedulers http://blogs.msdn.com/slavao/archive/2005/08/18/453354.aspxhttp://blogs.msdn.com/slavao/articles/441058.aspxhttp://technet.microsoft.com/en-us/library/ms178144.aspx
  2. http://blogs.msdn.com/slavao/archive/2005/02/19/376714.aspxhttp://sqlserver.ro/blogs/cristians_blog/archive/2007/10/02/the-return-of-the-ring-buffers.aspxhttp://support.microsoft.com/default.aspx/kb/918483Two types of memory pressureVAS memory PressurePhysical memory pressureVAS Memory PressureRM notified throughReactive – notified by memory node Virtual or Shared memory interfaces fail to allocate a region of 4MB and belowRM doesn't get notified if size of a region above 4MBProactiveRM probes VAS for 4MB size Physical memory pressureInternalShrink of Buffer Pool causes internal pressureDynamic change of max server memory75% BP stolen by cacheWhen triggered reclaim page from cacheExternal (OS)Signaled by OS, wakes up RM and broadcast notification to memory clerksBP recalculates target commit upon, start shrinking if new target lower than current committed till pressure disappearDe-commit in non-awe modeFree up physical memory in AWE mode (different from SQL Server 2000)BP only monitors external memory pressure
  3. stolen pages(perfmon) = sum of single pages (clerks)