# Virtio driver performance on FreeBSD 9.1



## nikolaii (Jul 18, 2013)

Hello,

I have the following setup:

a Samsung SSD 840 Pro drive of 128 GB
a Debian Wheezy (7.1) as a KVM host
multiple Debian 7.1 and FreeBSD 9.1 guests on top of it

I have installed the virtio drivers on all guests, and configured the KVM domain.xml files accordingly.

Then I ran some I/O tests using iozone. And as you can see on the results below, there is a big difference between the Debian guest and the FreeBSD guest.

Is there any option I could have forgotten to set up in FreeBSD that could explain this difference?

On the host server:


```
iozone -s 64M -r 4k -i 0 -i 1 -i 2
        Iozone: Performance Test of File I/O
                Version $Revision: 3.397 $
                Compiled for 64 bit mode.
                Build: linux-AMD64

        Run began: Fri Jul 19 07:14:56 2013

        File size set to 65536 KB
        Record Size 4 KB
        Command line used: iozone -s 64M -r 4k -i 0 -i 1 -i 2
        Output is in Kbytes/sec
        Time Resolution = 0.000001 seconds.
        Processor cache size set to 1024 Kbytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
                                                            random  random
              KB  reclen   write rewrite    read    reread    read   write
           65536       4  258532  553602   922146   969225 1523242  530324
```
On the FreeBSD guest:


```
iozone -s 64M -r 4k -i 0 -i 1 -i 2
        Iozone: Performance Test of File I/O
                Version $Revision: 3.397 $
                Compiled for 64 bit mode.
                Build: freebsd

        Run began: Fri Jul 19 07:36:15 2013

        File size set to 65536 KB
        Record Size 4 KB
        Command line used: iozone -s 64M -r 4k -i 0 -i 1 -i 2
        Output is in Kbytes/sec
        Time Resolution = 0.000027 seconds.
        Processor cache size set to 1024 Kbytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
                                                            random  random
              KB  reclen   write rewrite    read    reread    read   write
           65536       4   61687  128261   574681   580237  537510   20690
```
On the Debian guest:


```
iozone -s 64M -r 4k -i 0 -i 1 -i 2
        Iozone: Performance Test of File I/O
                Version $Revision: 3.397 $
                Compiled for 64 bit mode.
                Build: linux-AMD64

        Run began: Fri Jul 19 07:32:37 2013

        File size set to 65536 KB
        Record Size 4 KB
        Command line used: iozone -s 64M -r 4k -i 0 -i 1 -i 2
        Output is in Kbytes/sec
        Time Resolution = 0.000001 seconds.
        Processor cache size set to 1024 Kbytes.
        Processor cache line size set to 32 bytes.
        File stride size set to 17 * record size.
                                                            random  random
              KB  reclen   write rewrite    read    reread    read   write
           65536       4  119604  481670   878853   935172 1328093  473255
```
Thank you.
Nicolas


----------



## nikolaii (Jul 19, 2013)

Hi,

I'm adding some configuration information.

This is the setup in the domain.xml:

- Debian guest:


```
<disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/mapper/vg_vms-guest03'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
```

- FreeBSD guest:


```
<disk type='block' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <source dev='/dev/mapper/vg_vms-guest02'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
```

So as you can see everything is the same (except for the source device of course).

I can see that the virtio drivers (taken from this website http://people.freebsd.org/~kuriyama/virtio/) are properly loaded:


```
kldstat
Id Refs Address            Size     Name
 1   12 0xffffffff80200000 1323408  kernel
 2    5 0xffffffff81524000 4e98     virtio.ko
 3    1 0xffffffff81529000 5e98     virtio_pci.ko
 4    1 0xffffffff8152f000 52c8     virtio_blk.ko
 5    1 0xffffffff81535000 acc8     if_vtnet.ko
 6    1 0xffffffff81540000 3210     virtio_balloon.ko
```

Nicolas


----------

