Even though Hard disk drives are getting faster and faster, they’re still far behind compared to the speed at which other major hardware components of your computer operate (the CPU, GPU, RAM…). And since the hard disk is also the primary storage device where all your data is located, other more faster components, such as the CPU, has to literally ‘wait’ till data is first processed by the hard disk (say loading a program to RAM), before it can work on it.
So the point is, having not just a faster hard disk drive (whether it’s a rotational media or a Solid-state drive etc), but intelligently (effectively) managing the read/write requests send to it, can have a major impact on the system’s responsiveness. The software that’s involved in making those decisions is called the I/O scheduler, and each hard drive comes with one embedded into its BIOS chip.
But operating systems include one (or more) of their own (with added optimizations of their own), since they cannot customize the one that sits on the BIOS of the disk drive. Operating systems such as GNU/Linux has always included multiple I/O schedulers and nowadays it comes with three, commonly knows as: ‘NOOP’, ‘Deadline’ & ‘CFQ’. Most kernels use ‘CFQ’ by default as it’s the most conservative of the bunch. But depending on the technology used in your storage media, it might choose a different one (‘Deadline’ for instance, is better suited for SSD, or so they say).
Still, I couldn’t help but notice that under certain conditions, GNU/Linux slightly lacked that magical touch Microsoft Windows (especially from and after XP) showed when it came to being responsive under heavy disk I/O load. Sure there wasn’t a huge margin, still, it felt like there was some room for improvement (there always is 🙂 ).
So in my research, about three years ago, I came up with another disk I/O scheduler called BFQ that’s specifically designed to address this issue. After some reading and seeing some of the results, I was hooked into it!. Thus I installed it on Ubuntu 12.10 (back then) and was delighted with the improvements.
Since then, I’ve switched to Fedora (22) as my main operating system, and I thought, an article featuring BFQ and how to install it on Fedora 22 might come in handy for her users. But before I’m going to tell you how you can install it (it’s easy), please allow me as always, to share you with some of my own simple tests and their results as somewhat of a proof of what BFQ can actually do.
The tests are very simple. First I installed a fresh Fedora 22 into my test partition (one that I use to review all the operating systems) because I wanted a clean system. Then I boot into the OS a few times, letting things to settle down (you know, let the apps be done with creating configuration settings when run for the first time etc) and then I decided to run two tests, where both tests included copying a file (about 1.5GB) within my ‘Home’ folder because I wanted the HDD to get busy.
1). The first test is to wait 4 seconds after the file copy starts, and then open Firefox web browser and measuring how long the OS takes to open it. But before running it, I made sure Firefox will open a ‘Blank page’ and not an actual web page. And, after running the test, I cleared all of its cache (history, save passwords, offline-data etc) and rebooted the computer, all to keep the accuracy levels high, before running it again. This way, I ran it five times, for calculating average readings.
2). The second test involved opening LibreOffice Writer. And before running this test, on a previous instance, I opened LibreOffice Writer because when you run it for the first time, it’s slow because it has to create few startup configurations etc which could’ve affected the purity of the readings otherwise. Here too I waited four seconds after the file copying started, before attempting to open it, and rebooted the computer between each five tests as well.
Then I installed BFQ on Fedora 22 and ran the same tests on it. And based on all the data I gathered, I came up with the below two graphs so one can easily compare the performance of the two disk I/O schedulers and see the results for themselves.
(P.S: Please note that I used the default GnomeShell and added Firefox (added by default) & LibreOffice Writer to the Dash because it’s easier to open them that way).
Firefox open-up delay under CFQ & BFQ…
As you can see, under the same disk work load, BFQ was able to open-up Firefox web browser 39.3% faster than CFQ did!. This is no surprise to me since I’ve already seen the same kind of results under Ubuntu.
LibreOffice Writer open-up Delay (CFQ vs BFQ)…
Here too, as anyone can clearly see, BFQ outperformed CFQ by a big margin by opening up the LibreOffice Writer application 54.7% faster! (Not only on these occasions, overall, when the disk drive was dealing with heavy loads, the OS was much more responsive under BFQ than it when was under CFQ, obviously).
Now, coming back to the actual installation… There are many kernels available with BFQ but I prefer the one called ‘pf-kernel’. Mainly because in addition to BFQ, it also packs a couple of other utilities that are also known to improve the system’s responsiveness such as the BFS task scheduler (that which decides priority of processes) for instance. And pf-kernel, is available via third-party repository for Fedora 22, 21 & 20 users. But here I’ll be focusing on how to install it on Fedora 22.
Step 1: First of all, let’s enable the repository (a big thanks goes to Pavel for providing it). For that, open-up the terminal window and enter the below command:
sudo rpm -ivh http://rpm.hubbitus.info/Fedora22/Hubbitus-release-22-latest.noarch.rpm
Update (2016-01-21): Many users have complained that they were unable to install the pf-kernel even after adding repository. I looked into the issue and found that one of the mirrors holding the packages was not responding. Luckily I came up with a solution. All you have to do is to run the below command next which will open the file we just downloaded in text editor GUI. Then we’ll simply change the mirror to a working one.
sudo gedit /etc/yum.repos.d/Hubbitus.repo
Now look for a text line that has the below text:
-mirror (only that) from that text, save the change in text editor and close its window. That’s it, now you should be able to carry out rest of the installation. Good luck.
Step 2: Now, since Pavel updates the repository frequently, I cannot give you the exact command to install the latest available pf-kernel since due to the version, its name keeps changing. But luckily, I can show you how to find the currently available pf-kernel and then you can simply copy-&-paste it, for installing. For that, enter the below command:
sudo dnf list available kernel
This will show the currently available (& not yet installed) kernel list. In this output, look for the name that ends with ‘bfs.bfq.fc22’ as shown in the below screenshot.
Now simply copy the whole name (as highlighted in the screenshot) and then paste it at the end of the below command, without spaces:
sudo dnf install kernel-
To make it easier for you to understand, in this occasion, the command should as follows:
sudo dnf install kernel-4.1.9-200.hu.1.uksm.bfq.bfq.fc22
This will install the kernel and will add an entry to the GRUB boot menu as well.
Step 3: However, to enable BFQ there is one more thing that we have to do. Now this was not necessary in Ubuntu because as soon as the installation finished, you reboot the computer and select the BFQ kernel from the boot-menu and you’re good to go. But with this kernel (my best guess is that it has something to do with the way it was compiled), we have to add a configuration file so that BFQ is loaded and used as the default I/O scheduler.
For that, enter the below two commands (one after the other) into the terminal window:
sudo touch /etc/tmpfiles.d/set_IO_scheduler.conf
su -c 'echo "w /sys/block/sda/queue/scheduler - - - - bfq" > /etc/tmpfiles.d/set_IO_scheduler.conf'
Now you’re done. Now reboot the computer, choose the BFQ kernel from the GRUB menu (it should be selected as the default one) and enjoy the BFQ awesomeness! 😀 .
(P.S: Please remember that, this way, BFQ will be applied to your primary hard disk drive only and won’t apply to all the drives attached to your computer. If you want to enable it on all the drives (say that you have a gaming desktop computer with multiple disk drives), then you’ll have to replace the ‘/sda’ part of the last command with its device path, and append it to that configuration file. I don’t think this is a huge burden for most users since we usually use a single drive as the primary one.
Secondly, just like when you install any new non-official kernel, if you had software applications such as VirtualBox or Nvida or AMD/ATI GPU drivers with custom kernel modules, then you’ll have to re-build them as well).