Check or Change I/O Scheduler (elevator)

by Herb on 9 January 2008

A not-so-well known feature of Linux (aside from server administrators and gentoo tweekers probably) is the kernel’s I/O scheduler. I believe as of 2.6.18, CFQ (Complete Fair Queuing) has become the default for most distributions as it is well suited to low-latency desktop use. Previously anticipatory (which is better on slower drives) seemed to be the preferred choice. As computing power increased and hard drive seek times decreased other, more aggressive, schedulers became more efficient. I am not going to go into detail on how these schedulers work since it is quite a good read on wikipedia.

If you are curious here are some commands to check what is running:

Replace sda with your block device:

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

Changing to a different scheduler

1. Some distributions compile all the schedulers into the kernel and let you select using a kernel option at boot. Add the following to your kernel line in grub.conf (cfq,as,deadline,noop):

 elevator=cfq

2. The recommended way seems to be using a grub kernel setting at boot, but it can also be done hastily by simply echoing the scheduler to the /sys object.

# echo deadline > /sys/block/sda/queue/scheduler
3. In a source-based or more minimalist distribution it is possible to compile a kernel and specify the default/installed schedulers directly.

Device Drivers -->
          Block Devices -->
                   IO Schedulers -->
                         CFQ I/O Scheduler

It seems the default OpenSUSE 10.3 system installs all 4 schedulers, and defaults to CFQ. This works great for me in desktop applications, however if you are running a very task-specific server (such as database or file serving only) one of the other schedulers tailored for that task would be better. Similarly on older hardware (laptops, slow drives <7200rpm), a CFQ scheduler may be causing too much head movement and degrade performance noticeably.

Figure 1.1 Care of RedHat tests conducted for an Oracle database server.
Figure 1.2 Another Oracle database benchmark comparing all 4 schedulers from OracleSponge

Further discussion

Schedulers/Elevators were designed with traditional hard disks in mind (seeking heads). Now that SSDs are becoming more available and large USB flash memory common, there is no need to worry about scheduling the head movement efficiently, since there is none. A preliminary discussion didn’t get the attention it deserved. I will be able to test once I get access to some SSD media myself, but it would seem that the noop scheduler (i.e no advanced scheduling) would probably be the fastest on these types of media.

Leave a Comment

Previous post:

Next post: