17

I just installed Xubuntu 16.04-64bit to a second partition on my laptop. I noticed it seemed a bit slow at times, so I checked which IO scheduler it was using for that drive, which turns out to be deadline for all drives. I do have a couple of SSDs and hard drives so I know that "deadline" is best for SSDs and cfq for hard drives.

I booted into 14.04 on another partition and it is using cfq for the rotating drives and deadline for the SSD, as it should. I, also, looked into /etc/udev/rules.d to see if 14.04 was using a rule to configure for the type of drive but it wasn't there, so I assume that the kernel is doing it.

So I'm wondering if this is a bug or are they using "deadline" for everything now?

Update: The comment I wrote about /etc/udev/rules.d was a mistake. In fact I have been using a udev rule to change the scheduler (just as the answer has below) according to rotation type since I started using an SSD, a few years back. I guess I just forgot...getting old. Anyway, one of the references I used was Debian SSD optimization wiki.

Wouldn't it be a good idea if it was included? Just a suggestion!

6

With the release of 14.04 the default scheduler for the 3.13 kernel was changed from CFQ to Deadline.

There is no longer a separate server kernel and the CFQ sheduler is not suited to many server usage scenarios eg KVM write timeouts. There are even performance regressions on the desktop with USB devices.

  • 1
    Thanks for the read, very enlightening! The USB issue I've had often with SD cards and with may Android tablet in TWRP. In the latter, it would hang right at the end for several min. The KVM problem never show on my VB guests since they're on my SSD w/Deadline. – curt54 Jun 11 '16 at 14:28
32

The Ubuntu Kernel Team regularly run a lot of analysis of different simulated workloads on different file systems and I/O schedulers to get an idea of the best generic I/O scheduler choice. The general answer is that there is no perfect I/O scheduler choice for a generic configuration across all the different types installs for all the different kinds of media. The salient points to remember are:

  1. Systems are moving to SSD, so noop or deadline are best for these; noop has less CPU overhead than deadline.

  2. CFQ vs Deadline is a hard call. CFQ does allow greater flexibility. However, we found that for a wider range of simulated I/O operations, deadline provided lower latencies and slightly higher higher throughput than CFQ.

  3. I benchmark kernels regularly (each kernel test takes 3+ days to complete) for a range of file systems and I/O schedulers. From this, and other assorted data we try to make an informed decision on the best choice, see:

http://kernel.ubuntu.com/~cking/fs-tests/

There are pros/cons to all I/O schedulers, so any default is not perfect and the Ubuntu kernel team is always willing to have input to the default choice if compelling data and reasons show us to change otherwise.

  • 5
    We've moved to using CFQ as default for the Ubuntu Zesty 4.10 kernel and also enabled the new CONFIG_BLK_WBT_MQ (Multiqueue writeback throttling) as this resolves the dirty cache writeback issues with slow devices such as flash devices. – Colin Ian King Mar 13 '17 at 22:27
  • 1
    Are we perhaps going to see BFQ as default now that it is in kernel 4.12? – JauntyDoe Jul 2 '17 at 19:42
  • We will be evaluating this for 4.12/4.13, I did some early testing with kyber too but I will be revisiting these again once 4.12 is out this week. – Colin Ian King Jul 2 '17 at 19:51
  • In principle this question is only about the 16.04 kernel, but it still comes up in search :-). So here's a more recent update: Ubuntu has switched back to CFQ, matching the upstream default, in Ubuntu 17.04 (zesty) thru 18.10 (cosmic). – sourcejedi Nov 10 '18 at 21:52
  • 1
    Further update: Linux has disabled WBT when using CFQ or BFQ (at least by default), because it doesn't work well together. 2) If you want to evaluate the problem solved by WBT, I think you need to be aware the problem varies between devices (different firmwares). In your benchmark results, I can't even find what type of device was used. 3) I'm curious about your description of what WBT resolves. If you look at the cover letter on v2 of the WBT patch set, WBT is designed to handle buffered writes on fast flash, which can have very deep queues, and avoid starving readers on the same device. – sourcejedi Nov 23 '18 at 20:51
9

I don't know why the developers decided to choose deadline as default scheduler, maybe it is because most new computers ship with a SSD, on which normally the systems are installed. You can set the scheduler manually this way, in case you haven't already installed it ... install gksu :

Open a terminal and execute :

sudo apt install gksu  

Then execute this command :

gksudo gedit /etc/udev/rules.d/60-schedulers.rules  

Paste the following text into the empty file and save the changed file.

# set cfq scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="cfq"

# set deadline scheduler for non-rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"  

Reboot the operating system and now you are using the optimal schedulers for HDDs and SSDs.

  • Yeah, this what I had been using, as per my update in the question. But I'd think that since it's common today to have both types of drives they'd have this rule included on all Linux distributions. – curt54 Jun 9 '16 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.