In computing, when it comes to delivering excellent performance and stability, both software and hardware go hand in hand. Meaning that, even if you have the most powerful hardware, if your software or the operating system, is not properly optimized, then that can still lead to decreased performance & stability.
However, optimizing an operating system is no easy task either, as an OS is actually a collection of software tools, rather than a single entity, and thus, a major flow in a single core utility can negatively affect the entire OS, quite easily.
Take a file system for example. Let’s say that you have a fast spinning, newer hard disk drive etc. Let’s also say the file system is also well designed (less file fragmentation, fast seek times etc).
There is still, another important software utility called the ‘disk I/O scheduler’, that can has a big influence on the performance of a file system, specially under heavy disk I/O workloads.
Let me give you an example …
Nowadays, as computer users, we all multitask (quite heavily, I might add). You might be copying a large file to a different location on your HDD, then at the same time, decided to open an audio file, and then would also double click to open your web browser. And when doing all that, from the background, the operating system might also be receiving its daily software updates as well.
So in situations like these, if the throughput of your hard disk drive (I/O bandwidth) is not ‘shared intelligently’, it can affect the performance negatively. For instance, if the OS decided to give high priority to the file copying process, then the audio player and the web browser might take a long time to load. Or worse, the OS might even lose its ‘responsiveness’, by a lot. And the tool that is in control of managing the disk’s I/O bandwidth is, the ‘disk I/O scheduler’.
So again, supposing that one has a well designed file system & a fast disk drive, the disk I/O scheduler still plays a major role when it comes to maintaining a responsive operating system.
To keep the article as simple (and less boring) as possible, I’ll stop here.
In GNU/Linux, currently there are three main disk I/O schedulers available. They are called ‘CFQ’, ‘NOOP’, ‘Anticipatory’ and ‘Deadline’ (the ‘Anticipatory’ is now removed). Most distributions use the one called ‘CFQ’ (‘Completely Fair Queuing’ scheduler) but it really depends on the need of the users and the type of computing environments that distribution will be used upon.
In the past, Ubuntu’s desktop edition used ‘CFQ’ but with recent versions (including 12.10), ‘deadline’ has replaced ‘CFQ’. I have tested ‘CFQ’ and ‘deadline’, and I can see why ‘deadline’ is being used in Ubuntu, as it gives slightly higher throughput rates (very little) when copying files, and the responsiveness is also better than under ‘CFQ’, when multitasking.
That said, when comparing with Windows, though GNU/Linux is far far better than how it used to be, it still feels a bit less responsive, under heavy disk I/O based multitasking. For example, in Ubuntu, if I were to copy a file and while it is being copied, started to open several programs, then sure it slows down their loading times and it is to be expected.
But if I were to do something similar in Windows, then according to my experience, the OS’s responsiveness (plus the app loading times) is usually better than in Ubuntu, most probably because the disk I/O scheduler in Windows seems to be a bit better at keeping the OS more responsive, even when other disk I/O intensive programs are running from the background.
So out of my frustration, I searched for a solution. And came upon another disk I/O scheduler for GNU/Linux called ‘BFQ’ (it’s actually based on the code of ‘CFQ’). And even before I decided to install it, I got really excited because on its home page it says …
One of the nice features of BFQ is that, according to our results, whatever the load is, the disk is virtually as responsive if it was idle.
For example, even if one or more large files are being read or written, or else one or more virtual machines are performing I/O, starting a command/application takes about the same time as if the disk was idle.
It sounded like the perfect solution , so I decided to install in on my Ubuntu 12.10 and run few tests. Below are their details and the results.
I have a Core i3-2330M CPU, 4GB of DDR3 RAM, 320GB Toshiba SATA hard disk (7200 RPM). The tests were run under Ubuntu 12.10.
What were the tests?
I ran three tests in the default I/O scheduler that comes with Ubuntu 12.10 (‘deadline’) and then ran them all over again with ‘BFQ’ set as the scheduler. I ran each individual test 4 times, to get an average result, and between each test, I rebooted the computer to avoid disk and memory caching.
Test Number 1 …
According to the ‘BFQ’ developer ‘Paolo’, who is an assistant professor of Computer Science (University of Modena and Reggio Emilia, Italy), ‘BFQ’ also has the ability to give slightly higher disk throughput (sometimes 30% more!).
In other words, if I were to copy a file using ‘BFQ’, then it will be copied 30% faster, than other disk I/O schedulers.
Update (11/23/2012): This is actually not 100% accurate. Professor ‘Paolo’ was kind enough to put a comment and correct me. So let me comment him here …
… a disk scheduler can make a difference with respect to another one, in terms of throughput, only if there are at least two competing applications accessing the disk. Otherwise any good scheduler would achieve more or less the same performance, as it basically just passes requests to the disk in the same order as it receives them.
So I decided to test this first (and then move over to testing application loading times under heavy disk ‘I/O’ activity). All I did was very simple, I measured how many seconds Ubuntu takes while copying the Ubuntu 12.10 official disc image (800MB), while no other programs or tasks were running from the background.
I ran this test in both ‘BFQ’ and ‘deadline’. Below is the graph that I created by based on the average values.
As you can see, ‘deadline’ actually copied the file slightly faster than ‘BFQ’ did, though difference is very little (.5 seconds), it can make a difference while moving a big file (50 seconds change for copying 80GB of data).
And I could not see ‘BFQ’ improving my disk throughput as claimed.
Test Number 2 …
After the slight disappointment in the first test, I decided to test ‘BFQ’ performance under a heavy disk I/O workload, and how fast a certain application would load.
So the second test involved opening ‘LibreOffice Writer’ while copying a file that was about 2.1 GB.
Note: (for the extreme geeks: This was actually not a real file copy, instead, I used ‘dd’ to create a 2.1GB file with ‘block size’ set at ’1MB).
Once the 2.1GB file started to copy, I waited for 4 seconds approximately, and then clicked on the ‘LibreOffice Writer’ icon on my ‘Application Launcher, and measured how many seconds it takes for ‘Writer’ to be fully opened.
Again, I ran this test 4 times individually in each disk I/O scheduler and below is the graph based on the average results.
As you can see, the first time I couldn’t believe it actually, as ‘BFQ’ was able to open ‘LibreOffice Write’ application 262% faster than ‘deadline’ could!. And I also noticed two main things.
In ‘BFQ’, the time ‘Writer’ took to load varied a bit. For example, the first time, it took about 18 seconds. But the next time it was reduced to 10 seconds (remember, this is a ‘cold start’ of ‘Writer’. Meaning that I rebooted the PC between each test to avoid any memory Caching), third time 12 seconds and the fourth 17 seconds. And ‘LiberOffice’ started to load with a minimal of delay.
But in ‘deadline’, the variation was minimal (38, 37, 37, 38), though ‘LibreOffice Writer’ actually started to load ‘for real’, after the file copy was finished, as its ‘logo’ was just hanging there while the file was being copied.
Test Number 3 …
This very similar to the above test. To get more accurate results on how well ‘BFQ’ could perform under heavy disk I/O loads, I decided run another test. I also wanted a more practical example, so I decided not to use ‘dd’ to simulate a disk I/O activity.
This time, I copied a real ‘tar archive’ with a size of 1.5GB. And again, 4 seconds after it started to copy, I clicked on the Firefox’s icon on the Application Launcher. Then I measured how many seconds Firefox takes to load, and based on the average value, I came up with the below graph.
Note: (I cleared Firefox’s cache after running each test. Plus, also rebooted the computer too).
Because of the unusual and scary looking difference between the two rivals, I actually ran more than 8 individual tests . But the results were always same, with ‘BFQ’ opening Firefox 670% faster than ‘deadline’ did!.
Again, I did saw a few variations (seconds) while opening Firefox under ‘BFQ’ (8, 6, 9, 8) where it was quite minimal under ‘deadline’ (53, 52, 52, 52) but when compared the average loading times that ‘BFQ’ delivered, it just made me say, wow!.
How to Install it in Ubuntu ?
I could not find a PPA for adding ‘BFQ” into the Kernel that comes in Ubuntu (12.10). Luckily, there’s another kernel called ‘pf-kernel’ that comes with few ‘patches’ or features that are not included in the mainstream Kernel releases (including the ‘BFS’ task scheduler).
‘pf-kernel’ home page holds a ‘deb’ file that lets you easily install a Kernel that comes with the ‘BFQ’ as the default disk I/O scheduler. To install it, please follow the below steps …
Note: Installing a new Kernel is a bit dangerous thing. I did not encounter any issues (except the Ubuntu boot logo got displayed with a wrong aspect-ratio), but please use it at your own risk. I also don’t know if it will work in other Ubuntu versions either (only tested in 12.10).
Step 1: First of all, head over to
Update (2013/03/21): The above link doesn’t seem to be working anymore and the packages now are provided through here.
Step 2: Then download the latest Kernel package (the one with the name ‘linux-image …’ -- it has both 32-bit & 64-bit packages) & once the downloading completes, double click on it and follow the on-screen details of Ubuntu Software Center to install it.
When all is done, ‘pf-kernel’ will be used as the default one when you click on ‘Ubuntu’ from the GRUB menu. If you want, you can access the original Kernel by clicking on the ‘Advanced options for Ubuntu’ sub menu as well.
How to change between the disk I/O schedulers ?
Though ‘BFQ’ is the default disk I/O scheduler, ‘pf-kernel’ comes with ‘CFQ’, ‘Deadline’ and ‘NOOP’. And if you want, once installed, you can easily switch between the I/O schedulers, and do a bit of a testing by yourself too . For that, please follow the below steps (via this Ubuntu Forum thread).
Step 1: Open your Terminal window and enter the below command.
gksudo gedit /etc/default/grub
This will open a configuration file of GRUB bootloader.
Step 2: Then locate the below text line.
Step 3: Now simply copy and paste the below code after the existing “quite splash”, as shown below.
Note: You can also use others by simply replacing ‘deadline’ with ‘cfq’, ‘noop’ and ‘bfq’.
Now save your changes and exit the editor.
Step 4: Then enter the below command to properly update the configuration to GRUB.
Then wait for the ‘done’ message on the Terminal window.
Then reboot your computer for the changes to take effect. That’s it.
You can use the below command to see which disk I/O scheduler is being used, anytime you want.
Few closing words …
I too have only tested it on a single computer … so I cannot say much about its stability and other issues in a much broader sense. But from my short experience with it, I can say this much.
If you want to make Ubuntu impressively responsive so that it will open programs pretty fast when the disk drive is busy while attending to other disk I/O intensive tasks, then you should try ‘BFQ’!.
I also do hope that it will make it into Ubuntu, because everyone loves an OS that performs well under multitasking .
My tests are very basic ones and if you want more additional details, then please visit this page as it contains some complex tests and their results carried out by professor ‘Paolo’ and ‘Fabio’.
For those who are interested, assistant professor ‘Paolo’ has also created a 15 min video that compares ‘CFQ’ and ‘BFQ’ as well (below).