我有一个基于 btrfs 的四磁盘 RAID1 阵列系统。两个磁盘是 1TB 传统 HDD,另外两个是 128GB SSD。每个磁盘的大部分空间都由 LUKS 容器填充。在所有四个 LUKS 容器中,我都有一个执行 RAID1 的 btrfs 文件系统。
上述配置应该性能相当不错,但不幸的是,它的速度非常慢。以下是一些基准测试,通常在同一时间运行:
% dd if=/dev/zero of=tmpfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 1.18302 s, 908 MB/s
% dd if=/dev/zero of=tmpfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 1.66737 s, 644 MB/s
% dd if=tmpfile of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 1.61369 s, 665 MB/s
% echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
% dd if=tmpfile of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 8.05449 s, 133 MB/s
% echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
% dd if=/dev/zero of=tmpfile bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.66874 s, 402 MB/s
% echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
% dd if=tmpfile of=/dev/null bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 5.164 s, 208 MB/s
不太清楚该怎么做,但磁盘肯定似乎很慢。而且一般来说,当我查看时iotop
,我看到写入吞吐量为 5-10 MB/s 左右。不太好。
以下是更多信息:
% cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 834853 iterations per second
PBKDF2-sha256 548418 iterations per second
PBKDF2-sha512 366122 iterations per second
PBKDF2-ripemd160 508031 iterations per second
PBKDF2-whirlpool 175229 iterations per second
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 379.4 MiB/s 1552.0 MiB/s
serpent-cbc 128b 49.3 MiB/s 216.5 MiB/s
twofish-cbc 128b 129.3 MiB/s 258.3 MiB/s
aes-cbc 256b 325.3 MiB/s 1158.4 MiB/s
serpent-cbc 256b 65.0 MiB/s 213.1 MiB/s
twofish-cbc 256b 136.3 MiB/s 259.8 MiB/s
aes-xts 256b 1326.8 MiB/s 1333.5 MiB/s
serpent-xts 256b 224.4 MiB/s 216.7 MiB/s
twofish-xts 256b 255.5 MiB/s 257.2 MiB/s
aes-xts 512b 1034.8 MiB/s 1009.7 MiB/s
serpent-xts 512b 225.8 MiB/s 214.1 MiB/s
twofish-xts 512b 255.1 MiB/s 257.1 MiB/s
% lsmod | grep aes
aesni_intel 167936 18
aes_x86_64 20480 1 aesni_intel
lrw 16384 5 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64,twofish_x86_64_3way
glue_helper 16384 5 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64,twofish_x86_64_3way
ablk_helper 16384 4 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64
cryptd 20480 9 ghash_clmulni_intel,aesni_intel,ablk_helper
% uname -a
Linux steevie 4.7.0-0.bpo.1-amd64 #1 SMP Debian 4.7.5-1~bpo8+1 (2016-09-30) x86_64 GNU/Linux
如您所见,我在 Debian 8 上运行来自 的内核jessie-backports
。
此外,根据https://askubuntu.com/questions/246102/slow-ssd-dm-crypt-with-luks-encryption-in-ubuntu-12-10,我让 initramfs 在早期启动时加载cryptd
、aes_x86_64
和aesni_intel
模块。但是,重新启动并再次进行基准测试时,速度几乎完全相同。
知道这种糟糕的表现是从何而来的吗?