FreeBSD Disk Performance on a Cloud VPS with vfs.read_max
After getting setup on a new VPS running in the cloud via ToggleBox, I was browsing the Knowledge Base and came across this interesting tidbit:
Our SAN is optimized for random IO as that is more typical in a hosting environment. Enabling readahead under Linux will greatly increase sequential reads.
blockdev --setra 16384 /dev/xvda1Replace /dev/xvda1 with /dev/sda1 on older distributions. You can add this command to /etc/rc.local to make it persistent across reboots.
Because I am running FreeBSD 8.2-STABLE, the above tweaks do not apply to me. However, FreeBSD does have a vfs.read_max kernel tunable that behaves in much the same way. The default setting is very low, being set at a value of 8.
Some benchmarks of various settings I tried using bonnie (-s 8192) because I have 4GB RAM on this machine:
vfs.read_max=8 (default):
File './Bonnie.1614', size: 8589934592
Writing with putc()...done
Rewriting...done
Writing intelligently...done
Reading with getc()...done
Reading intelligently...done
Seeker 1...Seeker 2...Seeker 3...start 'em...done...done...done...
---------------------Sequential Output-------- ---Sequential Input-- --Random--
---------------Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
......8192 49868 24.6 50477 10.1 15540 4.0 33310 18.2 40572 7.0 235.9 1.5
vfs.read_max=128
File './Bonnie.2275', size: 8589934592
Writing with putc()...done
Rewriting...done
Writing intelligently...done
Reading with getc()...done
Reading intelligently...done
Seeker 1...Seeker 2...Seeker 3...start 'em...done...done...done...
---------------------Sequential Output-------- ---Sequential Input-- --Random--
---------------Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks---
Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU
.......8192 48717 24.0 52936 10.9 15433 3.9 58900 33.9 66069 13.0 406.7 2.4
As you can see, sequential input and random seeks and reads are much, much faster with a higher read_max value set, while writes remain about the same.