Especially for performance benchmarks it can be quite handy to have a zfs pool that’s not limited by the speed of the underlying hard drives or other block devices (like iSCSI or fibre channel). The Linux kernel has a nice block device driver that let’s you create virtual block devices that are RAM backed. To list the available options, use modinfo
# modinfo brd [...] parm: rd_nr:Maximum number of brd devices (int) parm: rd_size:Size of each RAM disk in kbytes. (int) parm: max_part:Num Minors to reserve between devices (int)
To create three virtual block devices with a size of 2GiB each for example, load the brd
module with the following options
# modprobe brd rd_nr=3 rd_size=2097152
which will create three devices named /dev/ramN
:
# ls -lah /dev/ram* brw-rw---- 1 root disk 1, 0 Apr 30 00:34 /dev/ram0 brw-rw---- 1 root disk 1, 1 Apr 30 00:34 /dev/ram1 brw-rw---- 1 root disk 1, 2 Apr 30 00:34 /dev/ram2
Note that the default value for the rd_nr
parameter is 16, which would result in 16 /dev/ramN
devices being created. However, the memory is still available until those virtual block devices are actually used.
Creating a zfs pool on these RAM backed block devices works just as with any other block device:
# zpool create tank ram0 ram1 ram2 # zpool status pool: tank state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 ram0 ONLINE 0 0 0 ram1 ONLINE 0 0 0 ram2 ONLINE 0 0 0 errors: No known data errors # zpool list NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT tank 5,95G 224K 5,95G - 0% 0% 1.00x ONLINE -
Reading from and writing to a filesystem on this RAM backed pool should be quite fast
# zfs create tank/fs # dd if=/dev/zero of=/tank/fs/testfile.img bs=1M count=5k 5120+0 records in 5120+0 records out 5368709120 bytes (5,4 GB) copied, 2,51519 s, 2,1 GB/s
Since the actual performance (throughput as well as IOPS) is heavily depending on the actual hardware, your mileage may vary here, of course. Please also keep in mind that writing zeros to a file with dd
is a quick and easy way to get a first ballpark number, it is not a proper performance benchmark however. You might want to have a look at bonnie++ et al. for that.
Pingback: OpenSSH cipher performance – /dev/blog