Storage is normally the slowest part of a system, and operating systems such as Linux try to limit I/O access with “tricks” like caching. The I/O scheduler may also matter if you have multiple programs accessing the same drive, and in Linux 4.12 implemented two new multi-queue block I/O schedulers, namely BFQ (Budget Fair Queuing) and Kyber that are meant to improve the performance of the systems. If you’re using Linux 5.2 you may even get further improvements since performance tweaks make application start-up times under load to be up to 80% faster.
I have never seen BFQ in action so far, but earlier this year, Paolo Valente, who is working for Linaro, made a video with an Acer Chromebook 15 showing Google Chrome launch time using the default mq-deadline schedule, and bfq-mq scheduler.
The test involves writing a 1.5GB file to the drive with dd, and clicking on the Google Chrome icon to start it up. With the mq-deadline scheduler, it takes several seconds to launch Chrome, while with bqf-mq the launch is almost instantaneous.
Some noted he did not clear the cache for the second run with the BFQ scheduler, but Paolo explained it did not matter:
In the first place I executed this test dropping caches, then found out that results are invariant w.r.t. dropping or not dropping. So, for fear of being too pedantic, I didn’t take the dropping step any longer in the version of the test I recorded.
Seeing a demo is all well and good, but I’d like to enable it on my systems to see how it performs. I’m running Ubuntu 18.04.3 LTS with Linux 5.0.0.
1 2 3 |
cd /sys/block/sda/queue/ cat scheduler [mq-deadline] none |
Oh. Why do I only have mq-deadline options? Ubuntu Wiki explains how to enable multi-queue schedulers:
1 2 |
sudo modprobe bfq-iosched sudo modprobe kyber-iosched |
Now we have access to kybr and bfq:
1 2 |
cat scheduler [mq-deadline] kyber bfq none |
I’m not sure how to enable bfq-mq like in the Chromebook demo though. Nevertheless, if you want to enable bfq, simply run the following command:
1 |
echo "bfq" | sudo tee /sys/block/sda/queue/scheduler |
Verify the scheduler is enabled:
1 2 |
cat scheduler mq-deadline kyber [bfq] none |
We’re good to go. I haven’t done much testing yet. I’ll provide some feedback after playing around a bit more. If you have already checked it out, please do comment about your experience.
It may also be worthwhile to read “Best I/O scheduler to use” from the Ubuntu Wiki page linked above, as “deadline” is the recommended scheduler for basically all use cases.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
I can confirm that BFQ is great. Tried it on desktop with liquorix.net kernel and felt substantial decrease of input-reaction lag
Are you using a hard drive or SSD? On SSD my tests always have mq-deadline winning.
I tried it with both
It does seem to help a lot. I’m running a backup in the background while using Firefox, and I can’t notice any significant slowdowns.
To make bfq scheduler permanent (i.e. selected automatically at boot time) I followed the instructions in the answer @ https://unix.stackexchange.com/questions/375600/how-to-enable-and-use-the-bfq-scheduler
There’s no need to modify grub anymore with Ubuntu 18.04.3
So basically we can create two files with the following content:
1. /etc/modules-load.d/bfq.conf
2. /etc/udev/rules.d/60-scheduler.rules
A next reboot bfq should be enabled. Alternatively, one can test it immediately with:
A great article and one that I have found works brilliantly on my S912 box running Coreelec.
This is the thread that I created over at the Coreelec forums about it.
https://discourse.coreelec.org/t/bfq-budget-fair-queuing/6605
As adamg correctly pointed out though, BFG was introduced in kernel 4.12, whereas CE is running on 3.14 on the S912.
And yet it works brilliantly by removing almost all the bottlenecks that I had before.
Thanks, but did you install CoreELEC with Linux 4.12+ on your Amlogic S912 box? If not, then BFQ is not supposed to work (it’s not there at all). If yes, then why don’t they update to Linux 4.12+?
The kernel is 3.41.29 and it works.
I’ve tested it with 2 S912 boxes with the same results.
I appreciate that the logic says that it can’t work because it can’t be present but it just does.
As far as 4.12+ is concerned, my understanding is that it’s not practical at this moment for this SOC.
The only way it could possibly if there was a backport to Linux 3.14, and somehow everything was enabled in your box. But I’m not aware of any. What is the output of?