Tag Archives: performance

Time filesystem operations using guestfish

A new feature we added to guestfish this week was the ability to time individual operations. We added this after we found a bug in the virtio block drivers where operations like mkfs.ext2 would run much more slowly than using the emulated IDE drivers in KVM.

It’s quite hard to characterize these problems, unless you can write short scripts to predictably reproduce them, and now with guestfish you can write such scripts.

You will need guestfish >= 1.0.55 to try out the examples below.

To demonstrate the mkfs.ext2 problem, save this script to a file and chmod +x it:

#!/usr/bin/guestfish -f
!dd if=/dev/zero of=/tmp/test.img bs=1024k count=100
config -drive file=/tmp/test.img,cache=off,if=virtio
#append elevator=noop
run
debug sh "for f in /sys/block/[hsv]d*/queue/rotational; do echo 0 > $f; done"
sfdiskM /dev/sda ,
time mkfs ext2 /dev/sda1

Run the script on the host (you don’t need to be root), and it will print the elapsed time of just the final mkfs command.

You can now play with variations on if=virtio|ide|scsi, different elevator=noop|cfq|.. algorithms in the guest, and writing 0 or 1 to the rotational knob.

For example:

if=virtio, (default elevator), rotational=0: mkfs takes 2.86 seconds*
if=virtio, (default elevator), rotational=1: mkfs takes 0.20 seconds
if=ide, (default elevator), rotational=0: mkfs takes 0.14 seconds
if=ide, (default elevator), rotational=1: mkfs takes 0.15 seconds
if=ide, elevator=noop, rotational=1: mkfs takes 0.20 seconds

* This dismal number is what caused us to file the original bug.

This is, I think, a relatively easy way to try out the effects of different combinations of drivers and settings on particular filesystem operations. Each test run takes around 30 seconds or so, and in just a few minutes you can easily explore quite a range of settings.

Leave a comment

Filed under Uncategorized