I/O schedulers

An important feature within the Linux I/O stack is a part of the kernel block layer called the I/O scheduler. The issue being addressed here is basically this: I/O requests are being more or less continually issued by the kernel (due to apps wanting to perform various file data/code reads and writes); this results in a continuous stream of I/O requests being ultimately received and processed by the block driver(s). The kernel folks know that one of the primary reasons that I/O sucks out performance is that the physical seek of a typical SCSI disk is really slow (compared to silicon speeds; yes, of course, SSDs (solid state devices) are making this a lot more palatable nowadays).

So, if we could use some intelligence to sort the block I/O requests in a way that makes the most sense in terms of the underlying physical medium, it would help performance. Think of an elevator in a building: it uses a sort algorithm, optimally taking people on and dropping them off as it traverses various floors. This is what the OS I/O schedulers essentially try to do; in fact, the first implementation was called Linus's elevator.

Various I/O scheduler algorithms exist (deadline, completely fair queuing (cfq), noop, anticipatory scheduler: these are now considered legacy; the newest as of the time of writing seem to be the mq-deadline and budget fair  queuing (bfq) I/O schedulers, with bfq looking very promising for heavy or light I/O workloads (bfq is a recent addition, kernel version 4.16). The I/O schedulers present within your Linux OS are a kernel feature; you can check which they are and which is being used; see it being done here on my Ubuntu 18.04 x86_64 box:

$ cat /sys/block/sda/queue/scheduler 
noop deadline [cfq]
$

Here, bfq is the I/O scheduler being used on my Fedora 28 system (with a more recent kernel):

$ cat /sys/block/sda/queue/scheduler 
mq-deadline [bfq] none
$

The default I/O scheduler here is bfq. Here's the interesting bit: the user can actually select between I/O schedulers, run their I/O stress workloads and/or benchmarks, and see which one yields the maximum benefit! How? To select the I/O scheduler at boot time, pass along a kernel parameter (via the bootloader, typically GRUB on an x86-based laptop, desktop or server system, U-Boot on an embedded Linux); the parameter in question is passed as elevator=<iosched-name>; for example, to set the I/O scheduler to noop (useful for systems with SSDs perhaps), pass the parameter to the kernel as elevator=noop

There's an easier way to change the I/O scheduler immediately at runtime; just echo(1) the one you want into the pseudo-file; for example, to change the I/O scheduler to mq-deadline,do the following:

# echo mq-deadline > /sys/block/sda/queue/scheduler 
# cat /sys/block/sda/queue/scheduler
[mq-deadline] bfq none
#

Now, you can (stress) test your I/O workloads on different I/O schedulers, thus deciding upon which yields the optimal performance for your workload.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset