仮想ディスクにZFSデバイスファイルを使って性能アップ
これまで2回に渡ってFreeBSD 10で導入されたハイパーバイザbhyveの使い方を紹介してきました。今回は仮想ディスクにZFSデバイスファイルを使うことで仮想ディスクI/
説明が重複するので、
ホスト側のセットアップ
ホスト側でbhyveを使うための設定を行います。システムを再起動しても有効にしておくために設定ファイルにも必要な設定を書き込んでおきます。
# kldload vmm # ifconfig tap0 create # ifconfig tap1 create # sysctl net.link.tap.up_on_open=1 net.link.tap.up_on_open: 0 -> 1 # ifconfig bridge0 create # ifconfig bridge0 addm bge0 addm tap0 addm tap1 up # cat /boot/loader.conf vmm_load="YES" # cat /etc/rc.conf | grep bridge0 cloned_interfaces="bridge0 tap0 tap1" ifconfig_bridge0="addm bge0 addm tap0 addm tap1" # cat /etc/sysctl.conf net.link.tap.up_on_open=1 #
ここではtap0をホストのUFS上のファイルを仮想ディスクとした仮想環境
ゲスト環境の構築
FreeBSD 10.
# fetch ftp://ftp.jp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/10.2/FreeBSD-10.2-RELEASE-amd64-disc1.iso.xz FreeBSD-10.2-RELEASE-amd64-disc1.iso.xz 100% of 413 MB 5844 kBps 01m13s # unxz FreeBSD-10.2-RELEASE-amd64-disc1.iso.xz
ホストのUFS上のファイルを仮想ディスクとする場合のインストール方法はこれまでと同じです。
# truncate -s 32G freebsd-10.2.img # sh /usr/share/examples/bhyve/vmrun.sh -c 2 -m 2G -t tap0 -d freebsd-10.2.img -i -I FreeBSD-10.2-RELEASE-amd64-disc1.iso freeb # bhyvectl --destroy --vm=freebsd-10.2 # sh /usr/share/examples/bhyve/vmrun.sh -c 2 -m 2G -t tap0 -d freebsd-10.2.img freebsd-10.2
ホストのZFSデバイスファイルを仮想ディスクとして使う場合には、
# zfs create -V 32G -o volmode=dev z/freebsd-10.2 # bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,/dev/zvol/z/freebsd-10.2 -s 4:0,ahci-cd,./FreeBSD-10.2-RELEASE-amd64-disc1.iso -l com1,stdio -c 2 -m 2G freebsd-10.2-on-zfs # bhyvectl --destroy --vm=freebsd-10.2-on-zfs # bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,/dev/zvol/z/freebsd-10.2 -l com1,stdio -c 2 -m 2G freebsd-10.2-on-zfs
truncate(1)コマンドでファイルを作成するのではなく、
bonnie++でベンチマーク
I/
# pkg install bonnie++ Updating FreeBSD repository catalogue... FreeBSD repository is up-to-date. All repositories are up-to-date. Updating database digests format: 100% The following 1 package(s) will be affected (of 0 checked): New packages to be INSTALLED: bonnie++: 1.97_3 The process will require 162 KiB more space. 57 KiB to be downloaded. Proceed with this action? [y/N]: y Fetching bonnie++-1.97_3.txz: 100% 57 KiB 58.7kB/s 00:01 Checking integrity... done (0 conflicting) [1/1] Installing bonnie++-1.97_3... [1/1] Extracting bonnie++-1.97_3: 100% #
bonnie++は性能の一つの側面を捉えるだけですので、
$ bonnie++ Writing a byte at a time...done Writing intelligently...done Rewriting...done Reading a byte at a time...done Reading intelligently...done start 'em...done...done...done...done...done... Create files in sequential order...done. Stat files in sequential order...done. Delete files in sequential order...done. Create files in random order...done. Stat files in random order...done. Delete files in random order...done. Version 1.97 ------Sequential Output------ --Sequential Input- --Random- Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP trybsd.localhost 4G 831 99 76708 11 33849 6 751 57 73333 10 499.9 38 Latency 33843us 1737ms 2056ms 717ms 1537ms 120ms Version 1.97 ------Sequential Create------ --------Random Create-------- trybsd.localhost -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ Latency 32708us 54us 64us 23808us 36us 36us 1.97,1.97,trybsd.localhost,1,1442308041,4G,,831,99,76708,11,33849,6,751,57,73333,10,499.9,38,16,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,33843us,1737ms,2056ms,717ms,1537ms,120ms,32708us,54us,64us,23808us,36us,36us $
$ bonnie++ Writing a byte at a time...done Writing intelligently...done Rewriting...done Reading a byte at a time...done Reading intelligently...done start 'em...done...done...done...done...done... Create files in sequential order...done. Stat files in sequential order...done. Delete files in sequential order...done. Create files in random order...done. Stat files in random order...done. Delete files in random order...done. Version 1.97 ------Sequential Output------ --Sequential Input- --Random- Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP trybsd.localhost 4G 802 99 89008 15 39636 5 1008 75 87941 9 968.3 30 Latency 32745us 4053ms 999ms 507ms 1059ms 94014us Version 1.97 ------Sequential Create------ --------Random Create-------- trybsd.localhost -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ Latency 44222us 44us 856us 28166us 40us 39us 1.97,1.97,trybsd.localhost,1,1442311572,4G,,802,99,89008,15,39636,5,1008,75,87941,9,968.3,30,16,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,32745us,4053ms,999ms,507ms,1059ms,94014us,44222us,44us,856us,28166us,40us,39us $
UFSとZFSの差をbonnie++の結果だけで考えるのはちょっとあれなのですが、
$ bonnie++ Writing a byte at a time...done Writing intelligently...done Rewriting...done Reading a byte at a time...done Reading intelligently...done start 'em...done...done...done...done...done... Create files in sequential order...done. Stat files in sequential order...done. Delete files in sequential order...done. Create files in random order...done. Stat files in random order...done. Delete files in random order...done. Version 1.97 ------Sequential Output------ --Sequential Input- --Random- Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP parancell.ongs. 16G 862 99 86112 6 41029 8 1141 93 86736 11 143.6 3 Latency 29915us 1850ms 2094ms 180ms 1384ms 219ms Version 1.97 ------Sequential Create------ --------Random Create-------- parancell.ongs.co.j -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ +++++ +++ Latency 18137us 13us 20us 88359us 10us 20us 1.97,1.97,parancell.ongs.co.jp,1,1442240935,16G,,862,99,86112,6,41029,8,1141,93,86736,11,143.6,3,16,,,,,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,+++++,+++,29915us,1850ms,2094ms,180ms,1384ms,219ms,18137us,13us,20us,88359us,10us,20us $
$ bonnie++ Writing a byte at a time...done Writing intelligently...done Rewriting...done Reading a byte at a time...done Reading intelligently...done start 'em...done...done...done...done...done... Create files in sequential order...done. Stat files in sequential order...done. Delete files in sequential order...done. Create files in random order...done. Stat files in random order...done. Delete files in random order...done. Version 1.97 ------Sequential Output------ --Sequential Input- --Random- Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP parancell.ongs. 16G 227 99 51994 5 48555 7 617 98 146090 10 310.8 5 Latency 129ms 28525ms 1533ms 104ms 455ms 349ms Version 1.97 ------Sequential Create------ --------Random Create-------- parancell.ongs.co.j -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 27446 69 +++++ +++ +++++ +++ 20718 99 20059 99 6581 100 Latency 9705us 140us 299us 13659us 119us 463us 1.97,1.97,parancell.ongs.co.jp,1,1442243865,16G,,227,99,51994,5,48555,7,617,98,146090,10,310.8,5,16,,,,,27446,69,+++++,+++,+++++,+++,20718,99,20059,99,6581,100,129ms,28525ms,1533ms,104ms,455ms,349ms,9705us,140us,299us,13659us,119us,463us $
ZFSデバイスファイルのほうが良い感じ
bonnie++の結果から、
SeqOut_ |
SeqOut_ |
SeqIn_ |
SeqIn_ |
|
---|---|---|---|---|
host UFS | 86112 | 41029 | 86736 | 143. |
host ZFS | 51994 | 48555 | 146090 | 310. |
guest UFS-virtdisk | 76708 | 33849 | 73333 | 499. |
guest ZFS-virtdisk | 89008 | 39636 | 87941 | 968. |
参考までにレイテンシーに関してまとめた表も掲載しておきます。こちらはmsとusの単位の結果が混在していますが、
SeqOut_ |
SeqOut_ |
SeqIn_ |
SeqIn_ |
Seq_ |
Seq_ |
Seq_ |
Rdm_ |
Rdm_ |
Rdm_ |
|
---|---|---|---|---|---|---|---|---|---|---|
host UFS | 1850 | 2094 | 1384 | 219 | 18137 | 13 | 20 | 88359 | 10 | 20 |
host ZFS | 28525 | 1533 | 455 | 349 | 9705 | 140 | 299 | 13659 | 119 | 463 |
guest UFS-virtdisk | 1737 | 2056 | 1537 | 120 | 32708 | 54 | 64 | 23808 | 36 | 36 |
guest ZFS-virtdisk | 4053 | 999 | 1059 | 94 | 44222 | 44 | 856 | 28166 | 40 | 39 |
UFS仮想ディスクとZFS仮想ディスクでは、
無駄な処理をしないので速くなる
ホストのUFS上のファイルを仮想ディスクとする場合、
ホストのZFSデバイスファイルを仮想ディスクにすると、
実験していませんが、
こうしたベンチマークの結果はホストの設定やゲストの設定、