4285ch01.fm Draft Document for Review May 4, 2007 11:35 am
24 Linux Performance and Tuning Guidelines
laptop computer quite likely has different I/O requirements from a 10,000-user database
system. To accommodate this, four I/O elevators are available.
򐂰Anticipatory
The anticipatory I/O elevator was created based on the assumption of a block device with
only one physical seek head (for example a single SATA drive). The anticipatory elevator
uses the deadline mechanism described in more detail below plus an anticipation
heuristic. As the name suggests, the anticipatory I/O elevator “anticipates” I/O and
attempts to write it in single, bigger streams to the disk instead of multiple very small
random disk accesses. The anticipation heuristic may cause latency for write I/O. It is
clearly tuned for high throughput on general purpose systems such as the average
personal computer. Up to kernel release 2.6.18 the Anticipatory elevator is the standard
I/O scheduler. However most Enterprise Linux distributions default to the CFQ elevator.
򐂰Complete Fair Queuing (CFQ)
The CFQ elevator implements a QoS (Quality of Service) policy for processes by
maintaining per-process I/O queues. The CFQ elevator is well suited for large multiuser
systems with a vast amount of competing processes. It aggressively attempts to avoid
starvation of processes and features low latency. Starting with kernel release 2.6.18 the
improved CFQ elevator is the default I/O scheduler.
Depending on the system setup and the workload characterstic the CFQ scheduler can
slowdown a single main application, for example a massive database with its fairness
oriented algorithms. The default configuration handles the fairness based on process
groups which compete against each other. For example a single database and also all
writes via the page cache (all pdflush instances are in one pgroup) are considered as a
single application by CFQ that may compete against many background processes. It can
be useful to experiment with I/O scheduler subconfigurations and/or the deadline
scheduler in such cases.
򐂰Deadline
The deadline elevator is a cyclic elevator (round robin) with a deadline algorithm that
provides a near real-time behavior of the I/O subsystem. The deadline elevator offers
excellent request latency while maintaining good disk throughput. The implementation of
the deadline algorithm ensures that starvation of a process cannot occur.
򐂰NOOP
NOOP stands for No Operation, and the name explains most of its functionality. The
NOOP elevator is simple and lean. It is a simple FIFO queue that performs no data
ordering but simple merging of adjacent requests, so it adds very low processor overhead
to disk I/O. The NOOP elevator assumes that a block device either features its own
elevator algorithm such as TCQ for SCSI, or that the block device has no seek latency
such as a flash card.
1.4.4 I/O device driver
The Linux kernel takes control of devices using a device driver. The device driver is usually a
separate kernel module and is provided for each device (or group of devices) to make the
device available for the Linux operating system. Once the device driver is loaded, it runs as a
part of the Linux kernel and takes full control of the device. Here we describe SCSI device
drivers.
Note: With the Linux kernel release 2.6.18 the I/O elevators are now selectable on a
per disk subsystem basis and have no longer to be set on a per system level.