Why Virtual Machines suck when you run them from BTRFS files system
lists.fedoraproject.org
lists.fedoraproject.org
btrfs is currently optimized for normal applications that do open("foo", O_RDWR). With this mode, integrity semantics are quite loose in POSIX.
Because VMs emulate physical hardware with strong integrity semantics, they usually do either open("foo", O_DIRECT) or open("foo", O_SYNC).
btrfs sucks for O_SYNC. It's not just VMs, databases also tend to make heavy use of O_SYNC.
Given where BTRFS is right now development wise, it's not at all surprising O_SYNC hasn't been optimized yet.
Having said that, I'd love to know if there are automated tests within the kernel that could verify integrity/correctness/performance of things like filesystem drivers in a simple and automated form. Something like it could prevent surprising developments performance regressions like this and provide better mapping between what you want to do and how you should do it.
http://xfs.org/index.php/Getting_the_latest_source_code#XFS_...
and
http://oss.sgi.com/cgi-bin/gitweb.cgi?p=xfs/cmds/xfstests.gi...
I dont think the problem is purely buffered vs. unbuffered IO. The guest operating system will have performed some block coalescing anyway so the block requests will often NOT be 4K chunks but should have slightly larger granularity. However, if you use a COW based virtual disk layout like QCOW2 which I guess is standard in KVM, you may see additional scattered IO.
I think it is weird to be using COW virtual disk layouts on a file system that natively supports COW as is the case with BTRFS. I would be curious to see what the performance of raw sparse files on BTRFS is vs. qcow2 etc.
Except for btrfs, where it would make the whole thing even less efficient (because now the only cost is the waiting around for threads, not even the random seek on your platters).
And as a result, I disagree with your "and exacerbated by". BTRFS's problem becomes worse on SSDs (qualitatively) because the random read itself is almost free, and all of the cost is in the context switching done by the FS, instead of only 80~90% of that cost.
Fedora is not a Linux you recommend for someone who doesn't know what they are doing and, if you know VM performance sucks with BtrFS, please, by all means, add another partition and use ext4 (or 3 or 2 or XFS or anything you think may offer you better performance)