Monday, April 26, 2010

Optimize EX3 filesystem performance

Suppose your /etc/fstab looks like this:
/dev/sda1 /     ext3    errors=remount-ro        0 1
/dev/sda9 /home ext3    defaults                 0 2

Turning off atime

If atime is on, every time a file is accessed, whether for read or write, a small change is written to the file detailing the last access time. To disable atime on ext3 partitions:
/dev/sda1 /     ext3  errors=remount-ro,noatime,nodiratime 0 1
/dev/sda9 /home ext3  defaults,noatime,nodiratime 0 2

Disable extended user attributes

Most likely you do not need extended user attributes, so disable them.
/dev/sda9 /home ext3  defaults,noatime,nodiratime,nouser_xattr 0 2

Use journal data writeback

By default journal data ordered option is used. According to this report, you can double read performance. You can simply turn on writeback for any filesystem (but root) by adding data=writeback.
/dev/sda1 /     ext3    errors=remount-ro        0 1
/dev/sda9 /home ext3    defaults,noatime,nodiratime,nouser_xattr,data=writeback 0 2

Journal data writeback for root filesystem

If you try to do this with root (/) filesystem you will get an error message during the boot and the root filesystem remains read-only. Remount it read-write:
mount -n -o remount, rw /
You need setup default filesystem option for root:
deby:~# tune2fs -o journal_data_writeback /dev/sda1
deby:~# tune2fs -l /dev/sda1 | grep 'Default mount option'
Default mount options:    journal_data_writeback
Now you can reboot your system so your changes take effect.

Deactivate barriers

Write barriers enforce proper on-disk ordering of journal commits, making volatile disk write caches safe to use, at some performance penalty. Deactivating barriers make sense if you have battery-backed storage only.
/dev/sda9 /home ext3  defaults,noatime,nodiratime,nouser_xattr,data=writeback,barrier=0 0 2

Avoid buffer heads association

Do not attach buffer_heads to file pagecache. This works together with data writeback option.
/dev/sda9 /home ext3  defaults,noatime,nodiratime,data=writeback,barrier=0,nobh 0 2

Extend commit interval

This options let sync all data and metadata every N seconds. The default value is 5 seconds.
/dev/sda9 /home ext3  defaults,noatime,nodiratime,nouser_xattr,data=writeback,barrier=0,nobh,commit=30 0 2
Have a look at more mount options here. Reboot your computer so all fine tunning take place.

No comments :

Post a Comment