應用程式使用 libc 時,可透過 libioil
程式庫提升 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, 45.6925 s, 470 MB/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, 15.735 s, 1.4 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=5
[libioil] Intercepting write of size 1073741824
5+0 records in
5+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 4.13708 s, 1.3 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, 4.18626 s, 1.3 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, 4.12114 s, 1.3 GB/s
部分程式 (包括 coreutils
套件中的大多數 GNU 公用程式) 都有解構函式,可在結束時關閉 stderr。也就是說,雖然攔截程式庫適用於許多基本指令 (例如 cp 和 cat),但無法查看攔截程式庫產生的摘要。