DevEnv

Installing PMDK[1]

PMDK 是一系列包的总称,随着英特尔傲腾业务的终止,这些包逐渐不再被维护。Debian 12 软件仓库中目前只剩 libpmem ( 低级操作 )、libpmemblk 等主要包,或者手动从 Github 自行安装。

1
2
$ apt search pmem
$ apt-get install <library>

e.g. libpmem[2]

1
2
3
Runtime: libpmem1
Dev : libpmem-dev
Debug : libpmem1-debug

不装 dev 会导致编写程序时没有头文件

Installing NDCTL[3]

The ndctl utility is used to manage the libnvdimm (non-volatile memory device) sub-system in the Linux Kernel.

1
$ apt install ndctl daxctl

Installing IPMCTL[4]

ipmctl is an open source utility created and maintained by Intel to manage Intel® Optane™ persistent memory modules.

Now enjoy PMDK!

Docs

Documentation for Linux PMEM and CXL tools

使用 PMDK APIs

这里应属于 devdax.[5] 测试了 PPM Chp.03 的配套代码[6],主要是 Linux Block I/O 与 PMDK Memory-Mapping 对比。

1
2
3
4
5
Linux Block I/O ←→ PMDK
---------------------------------
mmap() ←→ pmem_map_file()
msync() ←→ pmem_persist()
munmap() ←→ pmem_unmap()

PMDK 是内存映射的,并且官方文档提到比一般的 Block I/O 更快。这由于 DAX 特性支持原地映射存储为内存 ( 概念上 ),省去了内核页缓存和磁盘 I/O 的时间,对需要频繁 I/O 的数据密集型应用尤佳。

不过使用 4KB 文件实测要慢一些,可能是文件太小了,也可能是测试方式不合理。

1
2
3
4
$ dd if=/dev/zero of=testfile bs=4k count=1
$ od -c testfile # see it is all zeros
$ ./mmap_example testfile
$ od -c testfile # see the result of this program

可惜傲腾已死,很多包不再能够通过软件包仓库安装,PPM 的一些例程已不可用。重心仍应放在 NUMA Mode 上。

其他

傲腾内存持久编程手册[7]


  1. Installing PMDK using Linux Packages | Persistent Memory Documentation ↩︎

  2. libpmem | PMDK ↩︎

  3. Installing NDCTL and DAXCTL Packages on Linux | NDCTL User Guide ↩︎

  4. Installing IPMCTL packages on Linux | IPMCTL User Guide ↩︎

  5. Creating Namespaces ↩︎

  6. Apress/programming-persistent-memory: Source Code for ‘Programming Persistent Memory: A Comprehensive Guide for Developers’ by Steve Scargall
    PMDK 也有配套代码,在 /src/examples 目录下 ↩︎

  7. 持久内存快速编程手册.pdf ↩︎