BFQ (Budget Fair Queuing)

My scenario.

S912 box.

If I am, for example, playing a video file from a physical source connected to the box (USB flash drive/SSD/HDD, Micro SD Card) and copying a large file to the same source, even when the sources perform at a very decent speed when used with a PC, the consecutive read and write will often result in the video and audio pausing when the write speed hits close to 0 and stuttering badly when write speed portions are low.

The same can also be true if reading from one source e.g. Micro SD card, and writing to USB flash drive/SSD/HDD.

It can also be an issue when recording through TV Headend whilst watching a video file.

With the S912 box only having USB 2.0 ports and with a likely basic form of SD Card slot/controller, I simply put things down to a natural limitation of the box.

But then I came across this article on CNX Software regarding BFG, with a video demonstration to show how it works and it’s benefits.

In the comments section, the site owner, Jean-Luc Aufranc explained what was required to activate the option, creating a couple of files and executing a couple of commands.

So I tried it.

Paraphrasing Jean-Luc’s instructions:

Create two files in the following locations with the stated content:

  1. /etc/modules-load.d/bfq.conf

bfq

  1. /etc/udev/rules.d/60-scheduler.rules

ACTION==“add|change”, KERNEL==“sd*[!0-9]|sr*”, ATTR{queue/scheduler}=“bfq”

To test it immediately, run the following commands:

udevadm control --reload
udevadm trigger

Then whilst I played a video file from the Micro SD card, I copied a large file to it. Virtually no stutter (just twice for a fraction of a second) and no pausing.

Repeating the same test with a USB Flash drive and an External SSD was equally as good.

The only notable thing was that the large file being copied did take a little longer to complete but I guess this is down to the idea of the queuing process.

BFG might not be as relevant to the latest boxes with high speed throughput of the USB ports but might well be of use to many others, so worth considering as a default option in Coreelec?

bfq was only introduced in Linux kernel 4.12 and as I’m sure you know the Linux kernel for S912 that we use is 3.14.

Not possible to implement this request at this time for that reason.

Yes, that would seem perfectly logical.

But the odd thing is that it works, so a bit of a head scratcher and one to put on the CE back burner until 4.12 is used.

You should check used scheduler before and after

cat /sys/block/sd*/queue/scheduler