zoukankan      html  css  js  c++  java
  • linux disk i/o shceduler

    转自:http://baoz.net/linux-io-%E8%B0%83%E5%BA%A6%E7%AE%97%E6%B3%95/

    主要介绍anticipatory,deadline和CFQ三个磁盘调度算法,在linux编译内核的时候你可以选择。这三个调度算法在linux内核的帮助上都有简单的解释。大概的意思是如果你有数据库应用,最好选择deadline。http://www.ibm.com/developerworks/cn/linux/es-power5virtualization/index.html

    这里有说到SCSI和IO的调度算法的东西

    • noop —— fifo 排队
    • anticipatory —— 预期调度
    • deadline
    • cfq —— 始终公平排队

    CFQ从LINUX帮助看来说是适用于桌面系统。

    noop和anticipatory和deadline这几个需要学习一下

    http://blog.zhangjianfeng.com/?p=647

    这个文章也可以参考下

    http://www.wlug.org.nz/LinuxIoScheduler

    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 optimsation for different classes of workload.

    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 optimise disk access times.

    An IO scheduler can use the following techniques to improve performance:

    Request merging
    The scheduler merges adjacent requests together to reduce disk seeking
    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.
    Prioritisation
    The scheduler has complete control over how it prioritises requests, and can do so in a number of ways

    All IO schedulers should also take into account resource starvation, to ensure requests eventually do get serviced!

    The Schedulers

    There are currently 4 available:

    • Noop Scheduler
    • Anticipatory IO Scheduler ("as scheduler")
    • Deadline Scheduler
    • Complete Fair Queueing Scheduler ("cfq scheduler")

    Noop Scheduler

    This scheduler only implements request merging.

    Anticipatory IO Scheduler ("as scheduler")

    The anticipatory scheduler is the default scheduler in older 2.6 kernels – 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.

    Deadline Scheduler

    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.

    Complete Fair Queueing Scheduler ("cfq scheduler")

    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, as does the latest Ubuntu release. As of the 2.6.18 kernel, this is the default schedular in kernel.org releases.

    Changing Schedulers

    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.

    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

    Which one should I use?

    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 RAID – 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.

    Tuning the IO schedulers

    The schedulers may have parameters that can be tuned at runtime. Read the linux documentation on the schedulers listed in the References section below

    More information

    Read the documents mentioned in the References section below, especially the linux kernel documentation on the anticipatory and deadline schedulers.

    References

    包子猜您可能还喜欢下列文章:

    1. Choosing an I/O Scheduler for Red Hat® Enterprise Linux® 4 and the 2.6 Kernel
    2. TCP performance tuning – how to tune linux
    3. linux 2.4内核升级到2.6内核
    4. Linux: Kernel Crash Dumps
    5. Write a Linux Hardware Device Driver
  • 相关阅读:
    Bayesian CTR Prediction for Bing
    Gaussian and Truncated Gaussian
    An Introduction to Variational Methods (5.3)
    An Introduction to Variational Methods (5.2)
    An Introduction to Variational Methods (5.1)
    Variational Bayes
    微软的一篇ctr预估的论文:Web-Scale Bayesian Click-Through Rate Prediction for Sponsored Search Advertising in Microsoft’s Bing Search Engine。
    第五十二课、命令行参数的应用------------------狄泰软件学院
    第五十一课、程序中的配置文件------------------狄泰软件学院
    第五十课、关于对话框(About)------------------狄泰软件学院
  • 原文地址:https://www.cnblogs.com/qi09/p/1826800.html
Copyright © 2011-2022 走看看