有没有人在 Linux 环回文件系统上做过任何性能/基准测试?到目前为止你的经历是什么。性能是否有任何严重下降?稳健性如何?
http://freshmeat.net/articles/virtual-filesystem-building-a-linux-filesystem-from-an-ordinary-file
Rob*_*b W 12
我已经对环回设备中的写操作进行了一些基准测试。结论如下:
首先,我在 8GB tmpfs 中的环回设备上运行了一个基准测试,并在该环回设备中运行了一个环回设备(在每次写入操作后同步):
tmpfs 中的 ext4:
Measured speed: 557, 567, 563, 558, 560, 559, 556, 556, 554, 557
Average speed : 558.7 MB/s (min 554 max 560)
Run Code Online (Sandbox Code Playgroud)
tmpfs 中 extf 中的 ext4:
Measured speed: 296, 298, 295, 295, 299, 297, 294, 295, 296, 296
Average speed : 296.1 MB/s (min 294 max 299)
Run Code Online (Sandbox Code Playgroud)
很明显,当使用带有同步写入的环回设备时,性能会有一些差异。
然后我在我的硬盘上重复了同样的测试。
ext4(硬盘,1000 MB,3 次):
Measured speed: 24.1, 23.6, 23.0
Average speed : 23.5 MB/s (min 23.0 max 24.1)
Run Code Online (Sandbox Code Playgroud)
ext4 中的 ext4(硬盘,945MB):
Measured speed: 12.9, 13.0, 12.7
Average speed : 12.8 MB/s (min 12.7 max 13.0)
Run Code Online (Sandbox Code Playgroud)
HDD 上的相同基准,现在每次写入后都不同步(time (dd if=/dev/zero bs=1M count=1000 of=file; sync)
,测量为<size>
/ <time in seconds>
)。
ext4(硬盘,1000 MB):
Measured speed: 84.3, 86.1, 83.9, 86.1, 87.7
Average speed : 85.6 MB/s (min 84.3 max 87.7)
Run Code Online (Sandbox Code Playgroud)
ext4 中的 ext4(硬盘,945MB):
Measured speed: 89.9, 97.2, 82.9, 84.0, 82.7
Average speed : 87.3 MB/s (min 82.7 max 97.2)
Run Code Online (Sandbox Code Playgroud)
(令人惊讶的是,环回基准测试看起来比原始磁盘基准测试更好,大概是因为环回设备的尺寸较小,因此在实际同步到磁盘上花费的时间更少)
首先,我在 /tmp (tmpfs) 中创建了一个 8G 的环回文件系统:
truncate /tmp/file -s 8G
mkfs.ext4 /tmp/file
sudo mount /tmp/file /mnt/
sudo chown $USER /mnt/
Run Code Online (Sandbox Code Playgroud)
然后我通过用数据填充已安装的环回文件来建立基线:
$ dd if=/dev/zero bs=1M of=/mnt/bigfile oflag=sync
dd: error writing '/mnt/bigfile': No space left on device
7492+0 records in
7491+0 records out
7855763456 bytes (7.9 GB) copied, 14.0959 s, 557 MB/s
Run Code Online (Sandbox Code Playgroud)
这样做之后,我在之前的环回设备中创建了另一个环回设备:
mkdir /tmp/mountpoint
mkfs.ext4 /mnt/bigfile
sudo mount /mnt/bigfile /tmp/mountpoint
sudo chown $USER /tmp/mountpoint
Run Code Online (Sandbox Code Playgroud)
并再次运行基准测试,十次:
$ dd if=/dev/zero bs=1M of=/tmp/mountpoint/file oflag=sync
...
7171379200 bytes (7.2 GB) copied, 27.0111 s, 265 MB/s
Run Code Online (Sandbox Code Playgroud)
然后我卸载了测试文件并将其删除:
sudo umount /tmp/mountpoint
sudo umount /mnt
Run Code Online (Sandbox Code Playgroud)
(类似对HDD的测试,除了我还添加count=1000
了防止测试填满我的整个磁盘)
(对于not-writing-on-sync测试,我运行了timed the dd
and sync
operation)