选择 Linux I/O 调度器 [英] Selecting a Linux I/O Scheduler

查看:18
本文介绍了选择 Linux I/O 调度器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到可以通过写入/sys/block/[disk]/queue/scheduler 来更改正在运行的内核上特定设备的 I/O 调度程序.例如,我可以在我的系统上看到:

I read that it's supposedly possible to change the I/O scheduler for a particular device on a running kernel by writing to /sys/block/[disk]/queue/scheduler. For example I can see on my system:

anon@anon:~$ cat /sys/block/sda/queue/scheduler 
noop anticipatory deadline [cfq] 

默认是完全公平的排队调度器.我想知道在我的自定义内核中包含所有四个调度程序是否有任何用处.似乎编译一个以上的调度程序没有多大意义,除非内核足够聪明,可以为正确的硬件选择正确的调度程序,特别是基于闪存的驱动器的noop"调度程序和传统驱动器的其他调度程序之一硬盘.

that the default is the completely fair queuing scheduler. What I'm wondering is if there is any use in including all four schedulers in my custom kernel. It would seem that there's not much point in having more than one scheduler compiled in unless the kernel is smart enough to select the correct scheduler for the correct hardware, specifically the 'noop' scheduler for flash based drives and one of the others for a traditional hard drive.

是这样吗?

推荐答案

/usr/src/linux/Documentation/block/switching-sched.txt,我可以在运行时更改任何特定块设备上的/O 调度程序.可能会有一些延迟,因为在使用新调度程序之前,先前调度程序的请求都已全部刷新,但即使在设备大量使用的情况下,也可以毫无问题地更改它.

As documented in /usr/src/linux/Documentation/block/switching-sched.txt, the I/O scheduler on any particular block device can be changed at runtime. There may be some latency as the previous scheduler's requests are all flushed before bringing the new scheduler into use, but it can be changed without problems even while the device is under heavy use.

# cat /sys/block/hda/queue/scheduler
noop deadline [cfq]
# echo anticipatory > /sys/block/hda/queue/scheduler
# cat /sys/block/hda/queue/scheduler
noop [deadline] cfq

理想情况下,将有一个调度程序来满足所有需求.它似乎还不存在.内核通常没有足够的知识来为您的工作负载选择最佳调度程序:

Ideally, there would be a single scheduler to satisfy all needs. It doesn't seem to exist yet. The kernel often doesn't have enough knowledge to choose the best scheduler for your workload:

  • noop 通常是内存支持的块设备(例如 ramdisk)和其他非旋转媒体(闪存)的最佳选择,在这些情况下,尝试重新安排 I/O 会浪费资源
  • deadline 是一个轻量级的调度器,它试图对延迟进行硬限制
  • cfq 尝试维护系统范围内 I/O 带宽的公平性
  • noop is often the best choice for memory-backed block devices (e.g. ramdisks) and other non-rotational media (flash) where trying to reschedule I/O is a waste of resources
  • deadline is a lightweight scheduler which tries to put a hard limit on latency
  • cfq tries to maintain system-wide fairness of I/O bandwidth

默认是 anticipatory 很长一段时间,它接受了很多调整,但在 2.6.33(2010 年初)中被删除.cfq 不久前成为默认设置,因为它的性能合理且公平是多用户系统(甚至单用户桌面)的一个很好的目标.对于某些场景——数据库经常被用作例子,因为它们往往已经有自己独特的调度和访问模式,并且通常是重要的服务(那么谁在乎公平?)——anticipatory 在这些工作负载上可调整以获得最佳性能的悠久历史,并且 deadline 非常快速地将所有请求传递给底层设备.

The default was anticipatory for a long time, and it received a lot of tuning, but was removed in 2.6.33 (early 2010). cfq became the default some while ago, as its performance is reasonable and fairness is a good goal for multi-user systems (and even single-user desktops). For some scenarios -- databases are often used as examples, as they tend to already have their own peculiar scheduling and access patterns, and are often the most important service (so who cares about fairness?) -- anticipatory has a long history of being tunable for best performance on these workloads, and deadline very quickly passes all requests through to the underlying device.

这篇关于选择 Linux I/O 调度器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆