📄 io_schedulers.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head> <title></title> <link rel="stylesheet" media="screen" type="text/css" href="./style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="./design.css" /> <link rel="stylesheet" media="print" type="text/css" href="./print.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="clear"><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#the_linux_i_o_scheduler" class="toc">The Linux I/O Scheduler</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#noop_scheduler" class="toc">Noop Scheduler</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#anticipatory_io_scheduler_as_scheduler" class="toc">Anticipatory IO Scheduler ("as scheduler")</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#deadline_scheduler" class="toc">Deadline Scheduler</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#complete_fair_queueing_scheduler_cfq_scheduler" class="toc">Complete Fair Queueing Scheduler ("cfq scheduler")</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#which_one_should_i_use" class="toc">Which one should I use?</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#tuning_the_io_schedulers" class="toc">Tuning the IO schedulers</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#more_information" class="toc">More information</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#references" class="toc">References</a></span></div></li></ul></li></ul></li></ul></div></div><h2><a name="the_linux_i_o_scheduler" id="the_linux_i_o_scheduler">The Linux I/O Scheduler</a></h2><div class="level2"><p> Credit to the following site for this page <a href="http://www.wlug.org.nz/LinuxIoScheduler" class="urlextern" title="http://www.wlug.org.nz/LinuxIoScheduler" rel="nofollow">http://www.wlug.org.nz/LinuxIoScheduler</a></p><p> The 2.6 Linux Kernel included selectable IO schedulers. IO Schedulers control the way the kernel commits reads and writes to disks - the intention of providing different schedulers is to allow better optimization for different classes of workload.</p><p>Without an IO scheduler, the kernel would basically just issue each request to disk in the order that it received them. This could result in massive thrashing of the disk subsystem - if one process was reading from one part of the disk, and one writing to another, it would have to seek back and forth across the disk for every operation. The schedulers main goal is to optimize disk access times.</p><p>An IO scheduler can use the following techniques to improve performance: </p><ul><li class="level1"><div class="li"> Request merging - The scheduler merges adjacent requests together to reduce disk seeking</div></li><li class="level1"><div class="li"> Elevator - The scheduler orders requests based on their physical location on the block device, and it basically tries to seek in one direction as much as possible.</div></li><li class="level1"><div class="li"> Prioritisation - The scheduler has complete control over how it prioritises requests, and can do so in a number of ways</div></li></ul><p> All IO schedulers should also take into account resource starvation, to ensure requests eventually do get serviced! The Schedulers</p><p>There are currently 4 available: </p><ul><li class="level1"><div class="li"> Noop Scheduler</div></li><li class="level2"><div class="li"> Anticipatory IO Scheduler (”as scheduler”)</div></li><li class="level2"><div class="li"> Deadline Scheduler</div></li><li class="level2"><div class="li"> Complete Fair Queueing Scheduler (”cfq scheduler”)</div></li></ul></div><!-- SECTION [1-1550] --><h3><a name="noop_scheduler" id="noop_scheduler">Noop Scheduler</a></h3><div class="level3"><p>This scheduler only implements request merging.</p></div><!-- SECTION [1551-1626] --><h3><a name="anticipatory_io_scheduler_as_scheduler" id="anticipatory_io_scheduler_as_scheduler">Anticipatory IO Scheduler ("as scheduler")</a></h3><div class="level3"><p>The anticipatory scheduler is the default scheduler - if you’ve not specified one, this is the one that will be loaded. It implements request merging, a one-way elevator, read and write request batching, and attempts some anticapatory reads by holding off a bit after a read batch if it thinks a user is going to ask for more data. It tries to optimise for physical disks by avoiding head movements if possible - one downside to this is that it probably give highly erratic performance on database or storage systems.</p></div><!-- SECTION [1627-2200] --><h3><a name="deadline_scheduler" id="deadline_scheduler">Deadline Scheduler</a></h3><div class="level3"><p>The deadline scheduler implements request merging, a one-way elevator, and imposes a deadline on all operations to prevent resource starvation. Because writes return instantly within linux, with the actual data being held in cache, the deadline scheduler will also prefer readers - as long as the deadline for a write request hasn’t passed. The kernel docs suggest this is the preferred scheduler for database systems, especially if you have TCQ aware disks, or any system with high disk performance.</p></div><!-- SECTION [2201-2733] --><h3><a name="complete_fair_queueing_scheduler_cfq_scheduler" id="complete_fair_queueing_scheduler_cfq_scheduler">Complete Fair Queueing Scheduler ("cfq scheduler")</a></h3><div class="level3"><p>The complete fair queueing scheduler implements both request merging and the elevator, and attempts to give all users of a particular device the same number of IO requests over a particular time interval. This should make it more efficient for multiuser systems. It seems that Novel SLES sets cfq as the scheduler by default. Changing Schedulers</p><p>The most reliable way to change schedulers is to set the kernel option ‘elevator’ at boot time. You can set it to one of “as”, “cfq”, “deadline” or “noop”, to set the appropriate scheduler.</p><p>It seems under more recent 2.6 kernels (2.6.11, possibly earlier), you can change the scheduler at runtime by echoing the name of the scheduler into /sys/block/<devicename>/queue/scheduler, where devicename is the base name of the block device, eg sda for /dev/sda</p></div><!-- SECTION [2734-3600] --><h3><a name="which_one_should_i_use" id="which_one_should_i_use">Which one should I use?</a></h3><div class="level3"><p>I’ve not personally done any testing on this, so I can’t speak from experience yet. The anticipatory scheduler will be the default one for a reason however - it is optimised for the common case. If you’ve only got single disk systems (ie, no <acronym title="Redundant Array of Inexpensive Disks">RAID</acronym> - hardware or software) then this scheduler is probably the right one for you. If it’s a multiuser system, you will probably find cfq or deadline providing better performance, and the numbers seem to back deadline giving the best performance for database systems.</p></div><!-- SECTION [3601-4148] --><h3><a name="tuning_the_io_schedulers" id="tuning_the_io_schedulers">Tuning the IO schedulers</a></h3><div class="level3"><p>The schedulers may have parameters that can be tuned at runtime. Read the linux documentation on the schedulers listed in the References section below </p></div><!-- SECTION [4149-4336] --><h3><a name="more_information" id="more_information">More information</a></h3><div class="level3"><p>Read the documents mentioned in the References section below, especially the linux kernel documentation on the anticipatory and deadline schedulers.</p></div><!-- SECTION [4337-4515] --><h3><a name="references" id="references">References</a></h3><div class="level3"><ul><li class="level1"><div class="li"> <a href="doku-offline/lib/exe/fetch.php?cache=cache&media=http%3A%2F%2Fawlinux1.alphaworks.ibm.com%2Fdeveloperworks%2Flinux390%2Fperf%2Ftuning_rec_dasd_ioScheduler.shtml%23begin" class="media mediafile mf_" title="http://awlinux1.alphaworks.ibm.com/developerworks/linux390/perf/tuning_rec_dasd_ioScheduler.shtml#begin">Tuning Linux 2.6 for the zSeries</a></div></li><li class="level2"><div class="li"> <a href="doku-offline/lib/exe/fetch.php?cache=cache&media=http%3A%2F%2Fawlinux1.alphaworks.ibm.com%2Fdeveloperworks%2Flinux390%2Fperf%2Ftuning_res_dasd_IO_scheduler.shtml%23begin" class="media mediafile mf_" title="http://awlinux1.alphaworks.ibm.com/developerworks/linux390/perf/tuning_res_dasd_IO_scheduler.shtml#begin">Benchmarking IO schedulers on the zSeries</a></div></li><li class="level2"><div class="li"> /usr/src/linux/Documentation/block/as-iosched.txt</div></li><li class="level2"><div class="li"> /usr/src/linux/Documentation/block/deadline-iosched.txt</div></li><li class="level2"><div class="li"> <a href="doku-offline/lib/exe/fetch.php?cache=cache&media=http%3A%2F%2Flwn.net%2FArticles%2F10102" class="media mediafile mf_" title="http://lwn.net/Articles/10102">Some Tunable Parameters for the CFQ Scheduler</a></div></li><li class="level2"><div class="li"> <a href="doku-offline/lib/exe/fetch.php?cache=cache&media=http%3A%2F%2Fwww.cs.rice.edu%2F%7Essiyer%2Fr%2Fantsched%2Fshines.html" class="media mediafile mf_html" title="http://www.cs.rice.edu/~ssiyer/r/antsched/shines.html">2003 Kerneltrap Thread Comparing IO Schedulers (Primarily AS vs. CFQ)</a></div></li></ul></div><!-- SECTION [4516-] --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -