Synchronous I/O on HDDs
Posted: 27. Feb 2012, 21:40
NB: If you are using an SSD, ignore the following, unless you want your SSD to die and destroy all your data.
So, the BSDs mostly use synchronous I/O and soft updates (i.e. metadata is written asynchronously). Linux uses asynchronous I/O by default, and has no support for soft updates. Common knowledge on Linux is that synchronous I/O will kill performance.
I do not think this is the case any more with modern hard drives. I am currently running with with my root and home partitions mounted synchronously, and everything works fine. Throughput is a little lower; but heavy I/O (like creating a VirtualBox drive) doesn't hang the system, which is usually what happens with the partitions mounted async.
(Note that I've turned off ext4 write barriers. They should not be necessary with synchronous I/O, and using them together results in very noticeable performance loss.)
Using synchronous I/O on a desktop has an obvious benefit: files saved to the disk will be written right away, instead of waiting around in RAM for a while. If there's a power outage, you have a lower risk of losing data.
OTOH, there are two detriments aside from loss of throughput that come to mind:
- More writes to the disk means shorter battery life
- More writes also might mean more wear and tear
Not sure to what extent those issues would crop up on Linux; BSDs manage synchronous I/O without killing batteries and hard drives, but they use soft updates, and Linux doesn't. So mounting your partitions synchronously might be a bad idea on a laptop, or if you have a cheap hard drive.
Anyway... I'm not of the opinion that synchronous I/O is better (or worse) on hard drives than asynchronous, but I think it should be noted that it may be a useful option for desktop users, especially those who have frequent power outages or problems with data loss; and that it does not in fact ruin desktop performance, unless you use it with ext4 or xfs and barriers enabled.
So, the BSDs mostly use synchronous I/O and soft updates (i.e. metadata is written asynchronously). Linux uses asynchronous I/O by default, and has no support for soft updates. Common knowledge on Linux is that synchronous I/O will kill performance.
I do not think this is the case any more with modern hard drives. I am currently running with with my root and home partitions mounted synchronously, and everything works fine. Throughput is a little lower; but heavy I/O (like creating a VirtualBox drive) doesn't hang the system, which is usually what happens with the partitions mounted async.
Code: Select all
$ mount -l
/dev/root on / type ext4 (rw,sync,noatime,barrier=0,commit=0)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/sda3 on /home type ext4 (rw,sync,noatime,barrier=0,commit=0)
tmpfs on /dev/shm type tmpfs (rw)
Using synchronous I/O on a desktop has an obvious benefit: files saved to the disk will be written right away, instead of waiting around in RAM for a while. If there's a power outage, you have a lower risk of losing data.
OTOH, there are two detriments aside from loss of throughput that come to mind:
- More writes to the disk means shorter battery life
- More writes also might mean more wear and tear
Not sure to what extent those issues would crop up on Linux; BSDs manage synchronous I/O without killing batteries and hard drives, but they use soft updates, and Linux doesn't. So mounting your partitions synchronously might be a bad idea on a laptop, or if you have a cheap hard drive.
Anyway... I'm not of the opinion that synchronous I/O is better (or worse) on hard drives than asynchronous, but I think it should be noted that it may be a useful option for desktop users, especially those who have frequent power outages or problems with data loss; and that it does not in fact ruin desktop performance, unless you use it with ext4 or xfs and barriers enabled.