![SSD 上的 LVM 写入延迟非常高](https://linux22.com/image/200017/SSD%20%E4%B8%8A%E7%9A%84%20LVM%20%E5%86%99%E5%85%A5%E5%BB%B6%E8%BF%9F%E9%9D%9E%E5%B8%B8%E9%AB%98.png)
我正在 SSD 和 postgresql 13 上对 lvm raid10 进行基准测试。
vgcreate tst3vg /dev/mapper/3600140500000[123456789a]00006a0000000000000
lvcreate --type raid10 -i 5 -m 1 -L 8850G -n lv_tst --raidintegrity y --raidintegritymode bitmap --raidintegrityblocksize 4096 tst3vg /dev/mapper/3600140500000[123456789a]00006a0000000000000
mkfs.xfs /dev/tst3vg/lv_tst
mount -o noatime,nodiratime /dev/tst3vg/lv_tst /tst3
初始化数据库...
pgbench -h 127.0.0.1 -p 15534 -i -s 1000 bench
pgbench -h 127.0.0.1 -p 15534 -c 300 -j 150 -T 172800 -s 1000 bench
dmsetup ls | grep tst3vg
...
tst3vg-lv_tst (254:477)
...
iostat -xm dm-477 /dev/mapper/3600140500000[123456789a]00006a0000000000000 5
...
Device r/s rMB/s r_await rareq-sz w/s wMB/s w_await wareq-sz aqu-sz %util
dm-102 790.80 29.90 0.32 38.72 3091.20 81.96 1.00 27.15 3.35 76.08
dm-126 812.00 29.91 0.34 37.72 3127.20 82.19 0.93 26.91 3.20 75.84
dm-158 814.40 29.91 0.34 37.61 3115.60 81.92 0.90 26.92 3.07 76.08
dm-17 798.00 29.91 0.53 38.38 3936.40 112.09 0.97 29.16 4.23 76.00
dm-203 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-251 805.40 29.90 0.32 38.02 3090.00 81.95 0.81 27.16 2.76 76.08
dm-282 815.00 29.91 0.33 37.58 3105.40 81.90 0.88 27.01 3.01 76.00
dm-309 782.60 29.91 0.35 39.14 3141.60 82.14 0.83 26.77 2.88 75.60
dm-358 776.80 29.90 0.56 39.42 3894.20 112.03 0.89 29.46 3.89 75.60
dm-415 807.80 29.91 0.35 37.92 3127.60 82.19 0.77 26.91 2.68 75.68
**dm-477 0.00 0.00 0.00 0.00 17799.00 397.26 36.20 22.85 644.28 58.24**
dm-50 781.40 29.90 0.36 39.18 3124.60 82.11 1.10 26.91 3.72 74.96
Device r/s rMB/s r_await rareq-sz w/s wMB/s w_await wareq-sz aqu-sz %util
dm-102 1128.80 40.76 0.34 36.98 3340.20 72.52 0.78 22.23 2.97 92.40
dm-126 1152.60 40.77 0.33 36.23 3324.00 72.63 0.75 22.37 2.87 92.08
dm-158 1149.00 40.77 0.34 36.34 3346.60 72.41 0.71 22.16 2.75 92.56
dm-17 1130.80 40.77 0.50 36.92 4434.20 113.51 0.82 26.21 4.21 92.88
dm-203 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-251 1144.20 40.76 0.35 36.48 3341.20 72.52 0.60 22.23 2.41 92.32
dm-282 1155.20 40.77 0.34 36.14 3346.60 72.41 0.69 22.16 2.70 92.32
dm-309 1117.80 40.77 0.39 37.35 3304.80 72.70 0.63 22.53 2.53 92.16
dm-358 1112.00 40.77 0.48 37.55 4448.00 113.34 0.67 26.09 3.51 92.32
dm-415 1145.60 40.77 0.34 36.45 3322.80 72.63 0.58 22.38 2.32 91.92
**dm-477 0.00 0.00 0.00 0.00 8317.80 162.57 4468.04 20.01 37164.29 58.64**
dm-50 1115.80 40.77 0.37 37.42 3338.80 72.55 0.90 22.25 3.41 92.16
...
设备 dm-447 是 lv_tst 。通常,LVM的写入延迟为20-40毫秒。我发现有时LVM的写等待非常高,相对磁盘的写延迟非常低。