拦截库

libioil 库可用于提高使用 libc 的应用对 DFuse 执行读写操作的性能。该库通过拦截来自应用的 POSIX 读写调用并直接在用户空间中为其提供服务来绕过内核。

使用 libioil

如需使用拦截库,请将 LD_PRELOAD 设置为指向 DAOS 安装目录中的共享库:

LD_PRELOAD=/usr/lib64/libioil.so

例如:

$ dd if=/dev/zero of=./foo bs=1G count=20
20+0 records in
20+0 records out
21474836480 bytes (21 GB, 20 GiB) copied, 14.1946 s, 1.5 GB/s

$ LD_PRELOAD=/usr/lib64/libioil.so dd if=/dev/zero of=./bar bs=1G count=20
20+0 records in
20+0 records out
21474836480 bytes (21 GB, 20 GiB) copied, 5.0483 s, 4.3 GB/s

您还可以使用 -lioil 标志在编译时将应用与拦截库相关联。

监控活动

如需为拦截库启用活动报告,请设置 D_IL_REPORT 环境变量。这会返回共享库析构函数中的活动摘要,通常在程序退出时返回。

分配给 D_IL_REPORT 的值定义了要记录到 stderr 的读取和写入调用的次数。如需记录所有调用,请将值设置为 -1。如需仅在程序退出时输出摘要,请将该值设置为 0

例如:

$ D_IL_REPORT=1 LD_PRELOAD=/usr/lib64/libioil.so dd if=/dev/zero of=./bar bs=1G count=20
[libioil] Intercepting write of size 1073741824
20+0 records in
20+0 records out
21474836480 bytes (21 GB, 20 GiB) copied, 5.17297 s, 4.2 GB/s

$ D_IL_REPORT=3 LD_PRELOAD=/usr/lib64/libioil.so dd if=/dev/zero of=./bar bs=1G count=5
[libioil] Intercepting write of size 1073741824
[libioil] Intercepting write of size 1073741824
[libioil] Intercepting write of size 1073741824
5+0 records in
5+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 1.27362 s, 4.2 GB/s

$ D_IL_REPORT=-1 LD_PRELOAD=/usr/lib64/libioil.so dd if=/dev/zero of=./bar bs=1G count=5
[libioil] Intercepting write of size 1073741824
[libioil] Intercepting write of size 1073741824
[libioil] Intercepting write of size 1073741824
[libioil] Intercepting write of size 1073741824
[libioil] Intercepting write of size 1073741824
5+0 records in
5+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 1.29935 s, 4.1 GB/s

某些程序(包括 coreutils 软件包中的大多数 GNU 实用程序)具有析构函数,用于在退出时关闭 stderr。这意味着,虽然拦截库适用于 cp 和 cat 等许多基本命令,但无法看到拦截库生成的摘要。