You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Configure persistent memory (PMEM) - Windows
3
+
description: Learn how to configure persistent memory (PMEM) for SQL Server on Windows, and how to create namespaces for PMEM devices.
4
+
author: briancarrig
5
+
ms.author: brcarrig
6
+
ms.reviewer: mikeray
7
+
ms.date: 09/21/2022
8
+
ms.topic: conceptual
9
+
ms.prod: sql
10
+
ms.technology: configuration
11
+
---
12
+
13
+
# Configure persistent memory (PMEM) for SQL Server on Windows
14
+
15
+
This article describes how to configure the persistent memory (PMEM) for [!INCLUDE[sqlv14](../../includes/sssql16-md.md)] and above on Windows.
16
+
17
+
## Overview
18
+
19
+
[!INCLUDE[sqlv15](../../includes/sssql19-md.md)] has a number of in-memory database features that rely on persistent memory. This document covers the steps required to configure persistent memory for SQL Server on Windows.
20
+
21
+
> [!NOTE]
22
+
> The term _enlightenment_ was introduced to convey the concept of working with a persistent memory aware file system. Direct access (DAX) extensions to the NTFS file system provide the ability to memory map files from kernel space to user space. When a file is memory mapped into user space the application can issue load/store instructions directly to the memory mapped file, bypassing the kernel I/O stack completely. This is considered an "enlightened" file access method. As of Windows Server 2022, this _enlightenment_ functionality is available on both Windows and Linux platforms.
23
+
24
+
## Configure the devices
25
+
26
+
### Create namespaces for PMEM devices
27
+
28
+
In Windows, use the `ipmctl` utility to configure the PMEM disks (referred to as namespaces in Linux). You can find Intel® Optane™ specific instructions [here](https://www.intel.com/content/www/us/en/developer/articles/guide/qsg-part3-windows-provisioning-with-optane-pmem.html). Details on supported PMEM hardware on different Windows versions are at [Understand and deploy persistent memory](/azure-stack/hci/concepts/deploy-persistent-memory#supported-hardware). PMEM disks should be interleaved across PMEM NVDIMMs and can provide different types of user-space access to memory regions on the device. For more on interleaved sets in Windows see [here](/azure-stack/hci/concepts/deploy-persistent-memory#understand-interleaved-sets).
29
+
30
+
## PMEM disks
31
+
32
+
### Use PowerShell to examine PMEM disks
33
+
34
+
```powershell
35
+
#Get information about all physical disks
36
+
Get-PhysicalDisk
37
+
38
+
#Review logical configuration of PMEM disks
39
+
Get-PmemDisk
40
+
41
+
#Get information about PMEM devices
42
+
Get-PmemPhysicalDevice
43
+
44
+
#Get information about unused PMEM regions
45
+
Get-PmemUnusedRegion
46
+
```
47
+
48
+
### BTT and DAX
49
+
50
+
By default, `New-PmemDisk` will use the desired `FSDax` mode. Atomicity is set to the default of `None` rather than `BlockTranslationTable`. From a support perspective, BTT must be enabled for the transaction log, to mimic required sector mode semantics. Although use of [BTT](/azure-stack/hci/concepts/deploy-persistent-memory#block-translation-table) with NTFS is generally recommended, BTT is not recommended when using large pages, such as required for [DAX](/windows-server/storage/storage-spaces/persistent-memory-direct-access#dax-and-block-translation-table-btt).
Hybrid Buffer Pool enables buffer pool objects to reference data pages in database files residing on persistent memory (PMEM) devices, instead of copies of the data pages cached in volatile DRAM. This feature is introduced in [!INCLUDE[sqlv15](../../includes/sssql19-md.md)].
16
+
Hybrid Buffer Pool enables buffer pool objects to reference data pages in database files residing on persistent memory (PMEM) devices, instead of having to fetch copies of the data pages from disk and caching them in volatile DRAM. This feature was introduced in [!INCLUDE[sqlv15](../../includes/sssql19-md.md)] and is further enhanced in [!INCLUDE[sqlv16](../../includes/sssql22-md.md)].
Persistent memory (PMEM) devices are byte-addressable and if a direct access (DAX) persistent-memory aware file system (such as XFS, EXT4, or NTFS) is used, files on the file system can be accessed using the usual file system APIs in the OS. Alternatively, it can perform what is known as load and store operations against memory maps of the files on the device. This allows PMEM aware applications such as SQL Server to access files on the device without traversing the traditional storage stack.
20
+
Persistent memory (PMEM) devices are byte-addressable and if a direct access (DAX) persistent-memory aware file system (such as XFS, EXT4, or NTFS) is used, files on the file system can be accessed using the usual file system APIs in the OS. Alternatively, SQL Server can perform what are known as load and store operations against memory maps of the files on the PMEM device. This allows PMEM aware applications such as SQL Server to access files on the device without traversing the traditional storage stack.
20
21
21
-
The hybrid buffer pool uses this ability to perform load and store operations against memory mapped files, to leverage the PMEM device as cache for the buffer pool and storing database files. This creates the unique situation where both a logical read and a physical read are essentially the same operation. Persistent memory devices are accessible via the memory bus just like regular volatile DRAM.
22
+
The hybrid buffer pool uses this ability to perform load and store operations against memory mapped files, to leverage the PMEM device both as a cache for the buffer pool and a storage location for the database files. This creates the unique situation where both a logical read and a physical read become essentially the same operation. Persistent memory devices are accessible via the memory bus just like regular volatile DRAM.
22
23
23
-
Only clean data pages are cached on the device for the hybrid buffer pool. When a page is marked as dirty, it is copied to the DRAM buffer pool before eventually being written back to the PMEM device and marked as clean again. This page maintenance will occur during regular checkpoint operations in a manner similar to that performed against a standard block device.
24
+
By default, only clean data pages are cached on the PMEM module for the hybrid buffer pool. For a page to be modified and marked as dirty, it must be copied from the PMEM device to a DRAM buffer pool, modified and then eventually a copy of the modified page is written from DRAM back to the PMEM module, at which point it can be marked as clean again. This process occurs using normal background operations such as checkpoint, or the lazy writer, just as though the PMEM module were a standard block device.
24
25
25
-
The hybrid buffer pool feature is available for both Windows and Linux. The PMEM device must be formatted with a filesystem that supports DAX (DirectAccess). XFS, EXT4, and NTFS file systems all have support for DAX. SQL Server will automatically detect if data files reside on an appropriately formatted PMEM device and perform memory mapping of database files upon startup, when a new database is attached, restored, or created.
26
+
The hybrid buffer pool feature is available for both Windows and Linux. The PMEM device must use a filesystem that supports DAX (DirectAccess). XFS, EXT4, and the NTFS file systems all have support for DAX extensions, which provides access to the filesystem directly from user space. SQL Server will detect if any database data files reside on an appropriately configured PMEM disk device and automatically perform the necessary memory mapping of the database files upon database startup, or whenever a database is attached, restored, or created.
26
27
27
28
For more information, see:
28
29
29
-
*[Understand and deploy persistent memory (Windows)](/windows-server/storage/storage-spaces/deploy-pmem/)
30
-
*[Configure persistent memory (PMEM) for SQL Server on Linux](../../linux/sql-server-linux-configure-pmem.md)
31
-
30
+
*[Configure persistent memory (PMEM) for SQL Server on Windows](../configure-windows/configure-persistent-memory.md)(Beginning with SQL Server 2022).
31
+
*[Configure persistent memory (PMEM) for SQL Server on Linux](../../linux/sql-server-linux-configure-pmem.md).
32
32
33
33
## Enable hybrid buffer pool
34
34
@@ -40,7 +40,7 @@ The following example enables hybrid buffer pool for an instance of SQL Server:
40
40
ALTER SERVER CONFIGURATION SET MEMORY_OPTIMIZED HYBRID_BUFFER_POOL =ON;
41
41
```
42
42
43
-
By default, hybrid buffer pool is disabled at the instance scope. Note in order for the setting change to take effect, the SQL Server instance must be restarted. A restart is needed to facilitate allocating sufficient hash pages, to account for total PMEM capacity on the server.
43
+
By default, hybrid buffer pool is disabled at the instance scope. Note that in order for the setting change to take effect, the SQL Server instance must be restarted. A restart is needed to facilitate allocating sufficient hash pages, to account for the total PMEM capacity on the server.
44
44
45
45
The following example enables hybrid buffer pool for a specific database.
46
46
@@ -83,6 +83,12 @@ The following example lists the databases and the database level setting for hyb
Hybrid buffer pool with `Direct Write` behavior reduces the number of `memcpy` commands that need to be performed on modified data or index pages residing on PMEM devices. It does this by leveraging the durable persisted log buffer as a means to modify the page without having to copy it into one of the DRAM buffer pools. Instead pages in database files residing on PMEM devices are modified directly without the need to cache in a DRAM buffer pool and later asynchronously flush to disk. This behavior still adheres to write ahead logging (WAL) semantics, as the (log) records in the persisted transaction log buffer have been written, or hardened, to durable media. Considerable performance gains have been observed for transactional workloads using hybrid buffer pool and persisted log buffer together in this manner.
89
+
90
+
To enable direct write mode, enable hybrid buffer pool and [persisted log buffer](../../relational-databases/databases/add-persisted-log-buffer.md) for a database and enable startup [trace flag 809](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md).
91
+
86
92
## Best Practices for hybrid buffer pool
87
93
88
94
- When formatting your PMEM device on Windows, use the largest allocation unit size available for NTFS (2 MB in Windows Server 2019 and later) and ensure the device has been formatted for DAX (Direct Access).
@@ -94,3 +100,7 @@ SELECT name, is_memory_optimized_enabled FROM sys.databases;
94
100
- If the server scoped setting for hybrid buffer pool is disabled, the feature will not be used by any user database.
95
101
96
102
- If the server scoped setting for hybrid buffer pool is enabled, you can use the database scoped setting to disable the feature for individual user databases.
103
+
104
+
- When using [Persisted Log Buffer](../../relational-databases/databases/add-persisted-log-buffer.md), consider enabling start-up [trace flag 809](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md) to reduce CPU overhead and improve overall performance. Especially, if the workload is highly transactional, involving multiple data and index page modifications.
105
+
106
+
- As of [KB4538118](https://support.microsoft.com/en-us/topic/kb4538118-improvement-enable-hybrid-buffer-pool-read-caching-in-sql-server-2019-fb60b715-d1c6-5212-59f9-b76e546eacbd) read caching is enabled by default, with the hottest pages in the Hybrid buffer pool automatically promoted to a DRAM buffer pool to improve performance.
This topic describes how to add a persisted log buffer to a database in [!INCLUDE[sqlv15](../../includes/sssql19-md.md)] using [!INCLUDE[tsql](../../includes/tsql-md.md)].
26
+
This topic describes how to add a persisted log buffer to a database in [!INCLUDE[sqlv15](../../includes/sssql19-md.md)]and above using [!INCLUDE[tsql](../../includes/tsql-md.md)].
28
27
29
28
## Permissions
30
29
@@ -36,11 +35,11 @@ To configure a persistent memory device in [Linux](../../linux/sql-server-linux-
36
35
37
36
## Configure persistent memory device (Windows)
38
37
39
-
To configure a persistent memory device in [Windows](/windows-server/storage/storage-spaces/deploy-pmem/).
38
+
To configure a persistent memory device in [Windows](../../database-engine/configure-windows/configure-persistent-memory.md).
40
39
41
40
## Add a persisted log buffer to a database
42
41
43
-
The following examples adds a persisted log buffer.
42
+
The following example adds a persisted log buffer.
44
43
45
44
```sql
46
45
ALTERDATABASE<MyDB>
@@ -52,33 +51,59 @@ ALTER DATABASE <MyDB>
52
51
);
53
52
```
54
53
55
-
Note that the log file on the DAX volume will be sized at 20MB regardless of the size specified wih the ADD FILE command.
54
+
For example:
56
55
57
-
The volume or mount the new log file is placed must be formatted with DAX (NTFS) or mounted with the DAX option (XFS/EXT4).
56
+
```sql
57
+
ALTERDATABASE WideWorldImporters
58
+
ADD LOG FILE
59
+
(
60
+
NAME = wwi_log2,
61
+
FILENAME ='F:/SQLTLog/wwi_log2.pldf',
62
+
SIZE = 20MB
63
+
);
64
+
```
65
+
66
+
The log file on the DAX volume will be sized at 20 MB regardless of the size specified with the ADD FILE command.
67
+
68
+
The volume or mount the new log file is placed must be formatted with DAX enabled (NTFS) or mounted with the DAX option (XFS/EXT4).
58
69
59
70
## Remove a persisted log buffer
60
71
61
72
To safely remove a persisted log buffer, the database must be placed in single user mode in order to drain the persisted log buffer.
62
73
63
-
The following example places removes a persisted log buffer.
74
+
The following example removes a persisted log buffer.
[Transparent Data Encryption (TDE)](../security/encryption/transparent-data-encryption.md) is not compatible with persisted log buffer.
74
92
75
-
[Availability Groups](../../t-sql/statements/create-availability-group-transact-sql.md) can only use this feature on secondary replicas due to need for normal log writing semantics on the primary. However, the small log file must be created on all nodes (ideally on DAX volumes or mounts).
93
+
[Availability Groups](../../t-sql/statements/create-availability-group-transact-sql.md) can only use this feature on secondary replicas due to the requirement by the log reader agent for standard log writing semantics on the primary. However, the small log file must be created on all nodes (ideally on DAX volumes or mounts). In the event of a failover, the persisted log buffer path must exist, in order for the failover to be successful.
94
+
95
+
In cases where the path or file isn't present during an Availability Group failover event, or database startup, the database enters a `RECOVERY PENDING` state until the issue is resolved.
96
+
97
+
## Interoperability with other PMEM features
98
+
99
+
When both Persisted log buffer and [Hybrid Buffer Pool](../../database-engine/configure-windows/hybrid-buffer-pool.md) are jointly enabled, along with start-up [trace flag 809](../../t-sql/database-console-commands/dbcc-traceon-trace-flags-transact-sql.md), Hybrid buffer pool will operate in what is known as _Direct Write_ mode.
76
100
77
-
## Backup and restore operations
101
+
## Back up and restore operations
78
102
79
103
Normal restore conditions apply. If persisted log buffer is restored to a DAX volume or mount, it will continue to function, otherwise it can be safely removed.
80
104
81
105
## Next steps
82
106
83
-
-[How It Works (It Just Runs Faster): Non-Volatile Memory SQL Server Tail Of Log Caching on NVDIMM](/archive/blogs/bobsql/how-it-works-it-just-runs-faster-non-volatile-memory-sql-server-tail-of-log-caching-on-nvdimm)
84
-
-[Transaction Commit latency acceleration using Storage Class Memory in Windows Server 2016/SQL Server 2016 SP1](/archive/blogs/sqlserverstorageengine/transaction-commit-latency-acceleration-using-storage-class-memory-in-windows-server-2016sql-server-2016-sp1)
107
+
-[How It Works (It Just Runs Faster): Non-Volatile Memory SQL Server Tail Of Log Caching on NVDIMM](https://techcommunity.microsoft.com/t5/sql-server-blog/how-it-works-it-just-runs-faster-non-volatile-memory-sql-server/ba-p/3209699)
108
+
-[Transaction Commit latency acceleration using Storage Class Memory in Windows Server 2016/SQL Server 2016 SP1](https://techcommunity.microsoft.com/t5/sql-server-blog/transaction-commit-latency-acceleration-using-storage-class/ba-p/384995)
0 commit comments