首页 > 系统相关 >Linux I/O schedulers类型简介

Linux I/O schedulers类型简介

时间:2023-10-19 12:04:13浏览次数:34  
标签:schedulers 简介 Ubuntu 调度 deadline scheduler Linux requests


I/O schedulers attempt to improve throughput by reordering request access into a linear order based on the logical addresses of the data and trying to group these together. While this may increase overall throughput it may lead to some I/O requests waiting for too long, causing latency issues. I/O schedulers attempt to balance the need for high throughput while trying to fairly share I/O requests amongst processes.

I/O调度器试图通过基于数据的逻辑地址将请求访问重新排序为线性顺序并尝试将这些地址分组来提高吞吐量。虽然这可能会增加总体吞吐量,但可能会导致一些I/O请求等待时间过长,从而导致延迟问题。I/O调度器试图平衡对高吞吐量的需求,同时试图在进程之间公平地共享I/O请求。

Different approaches have been taken for various I/O schedulers and each has their own set of strengths and weaknesses and the general rule is that there is no perfect default I/O scheduler for all the range of I/O demands a system may experience.

对于各种I/O调度器采取了不同的方法,每个调度器都有自己的优势和劣势,一般规则是,对于系统可能经历的所有I/O需求范围,没有完美的默认I/O调度器。

Linux I/O schedulers类型简介_linux


Multiqueue I/O schedulers

Note: These are the only I/O schedulers available in Ubuntu Eoan Ermine 19.10 and onwards.

The following I/O schedulers are designed for multiqueue devices. These map I/O requests to multiple queues and these are handled by kernel threads that are distributed across multiple CPUs.

注意:这些是Ubuntu Eoan Ermine 19.10及以后版本中唯一可用的I/O调度器。

以下I/O调度器是为多队列设备设计的。这些将I/O请求映射到多个队列,这些请求由分布在多个CPU上的内核线程处理。

bfq (Budget Fair Queuing) (Multiqueue)
Designed to provide good interactive response, especially for slower I/O devices. This is a complex I/O scheduler and has a relatively high per-operation overhead so it is not ideal for devices with slow CPUs or high throughput I/O devices. Fair sharing is based on the number of sectors requested and heuristics rather than a time slice. Desktop users may like to experiment with this I/O scheduler as it can be advantageous when loading large applications.

设计用于提供良好的交互式响应,特别是对于较慢的I/O设备。这是一个复杂的I/O调度器,每次操作的开销相对较高,因此对于CPU速度较慢或I/O设备吞吐量较高的设备来说并不理想。公平共享是基于请求的扇区数量和启发式方法,而不是时间片。桌面用户可能喜欢试用这种I/O调度程序,因为它在加载大型应用程序时非常有利。

kyber (Multiqueue)
Designed for fast multi-queue devices and is relatively simple. Has two request queues:专为快速多队列设备设计,相对简单。有两个请求队列:

Synchronous requests (e.g. blocked reads) 同步请求(例如阻塞读取)

Asynchronous requests (e.g. writes) 异步请求(例如写入)

There are strict limits on the number of request operations sent to the queues. In theory this limits the time waiting for requests to be dispatched, and hence should provide quick completion time for requests that are high priority. 发送到队列的请求操作的数量有严格的限制。理论上,这限制了等待调度请求的时间,因此应该为高优先级的请求提供快速完成时间。

none (Multiqueue)
The multi-queue no-op I/O scheduler. Does no reordering of requests, minimal overhead. Ideal for fast random I/O devices such as NVME. 多队列无操作I/O调度程序。不重新排序请求,开销最小。非常适合NVME等快速随机I/O设备。

mq-deadline (Multiqueue)
This is an adaption of the deadline I/O scheduler but designed for Multiqueue devices. A good all-rounder with fairly low CPU overhead. 这是对截止日期I/O调度器的改编,但专为多队列设备设计。一个很好的全能型,CPU开销很低。

Non-multiqueue I/O schedulers
NOTE: Non-multiqueue have been deprecated in Ubuntu Eoan Ermine 19.10 onwards as they are no longer supported in the Linux 5.3 kernel. 注意:在Ubuntu Eoan Ermine 19.10以后的版本中,非多队列已被弃用,因为它们在Linux 5.3内核中不再受支持。

deadline
This fixes starvation issues seen in other schedulers. It uses 3 queues for I/O requests: 这修复了其他调度器中出现的饥饿问题。它使用3个队列来处理I/O请求:

Sorted

Read FIFO - read requests stored chronologically 读取FIFO-按时间顺序存储的读取请求

Write FIFO - write requests stored chronologically 写入FIFO-按时间顺序存储的写入请求

Requests are issued from the sorted queue inless a read from the head of a read or write FIFO expires. Read requests are preferred over write requests. Read requests have a 500ms expiration time, write requests have a 5s expiration time. 在读或写FIFO头的读取未到期时,从排序队列发出请求。读请求优先于写请求。读取请求的有效期为500毫秒,写入请求的有效期限为5秒。

cfq (Completely Fair Queueing)
Per-process sorted queues for synchronous I/O requests. 同步I/O请求的按进程排序的队列。

Fewer queues for asynchronous I/O requests. 异步I/O请求的队列更少。

Priorities from ionice are taken into account. 来自ionice的优先级被考虑在内。

Each queue is allocated a time slice for fair queuing. There may be wasteful idle time if a time slice quantum has not expired. 为每个队列分配一个时间片,用于公平排队。如果时间片量子尚未过期,则可能存在浪费的空闲时间。

noop (No-operation)
Performs merging of I/O requests but no sorting. Good for random access devices (flash, ramdisk, etc) and for devices that sort I/O requests such as advanced storage controllers. 执行I/O请求的合并,但不进行排序。适用于随机访问设备(闪存、ramdisk等)和对I/O请求进行排序的设备,如高级存储控制器。

Selecting I/O Schedulers
Prior to Ubuntu 19.04 with Linux 5.0 or Ubuntu 18.04.3 with Linux 4.15, the multiqueue I/O scheduling was not enabled by default and just the deadline, cfq and noop I/O schedulers were available by default. 在使用Linux 5.0的Ubuntu 19.04或使用Linux 4.15的Ubuntu 18.04.3之前,多队列I/O调度在默认情况下未启用,默认情况下只有deadline、cfq和noop I/O调度程序可用。

For Ubuntu 19.10 with Linux 5.0 or Ubuntu 18.04.3 with Linux 5.0 onwards, multiqueue is enabled by default providing the bfq, kyber, mq-deadline and none I/O schedulers. For Ubuntu 19.10 with Linux 5.3 the deadline, cfq and noop I/O schedulers are deprecated. 对于Linux 5.0版的Ubuntu 19.10或Linux 5.0版以上的Ubuntu 18.04.3,默认情况下会启用多队列,提供bfq、kyber、mq-dealine和none I/O调度器。对于截止日期为Linux 5.3的Ubuntu 19.10,不推荐使用cfq和noop I/O调度器。

With the Linux 5.0 kernels, one can disable these and fall back to the non-multiqueue I/O schedulers using a kernel parameter, for example for SCSI devices one can use: 使用Linux 5.0内核,可以禁用这些并使用内核参数返回到非多队列I/O调度器,例如,对于可以使用的SCSI设备:

scsi_mod.use_blk_mq=0
…add this to the GRUB_CMDLINE_LINUX_DEFAULT string in /etc/default/grub and run sudo update-grub to enable this option. …add this to the GRUB_CMDLINE_LINUX_DEFAULT string in /etc/default/grub and run sudo update-grub to enable this option. …将其添加到/etc/default/grub中的GRUB_CMDLINE_LINUX_DEFAULT字符串中,然后运行sudo update GRUB以启用此选项。

Changing an I/O scheduler is performed on a per block device basis. For example, for non-multi queue device /dev/sda one can see the current I/O schedulers available using the following: 更改I/O调度程序是在每个块设备的基础上执行的。例如,对于非多队列设备/dev/sda,可以使用以下内容查看当前可用的I/O调度器:

cat /sys/block/sda/queue/scheduler

noop deadline [cfq]

to change this to deadline use: 要将其更改为deadline,请使用:

echo “deadline” | sudo tee /sys/block/sda/queue/scheduler

For multiqueue devices the default will show: 对于多队列设备,默认值将显示:

cat /sys/block/sda/queue/scheduler
[mq-deadline] none
To use kyber, install the module: 要使用kyber,请安装模块:

sudo modprobe kyber-iosched
cat /sys/block/sda/queue/scheduler
[mq-deadline] kyber none
and enable it: 并启用它:

echo “kyber” | sudo tee /sys/block/sda/queue/scheduler
To use bfq, install the module: 要使用bfq,请安装模块:

sudo modprobe bfq
cat /sys/block/sda/queue/scheduler
[mq-deadline] kyber none
and enable it: 并启用它:

echo “bfq” | sudo tee /sys/block/sda/queue/scheduler
Tuning I/O Schedulers
Each I/O scheduler has a default set of tunable options that may be adjusted to help improve performance or fair sharing for your particular use case. The following kernel documentation covers these per-I/O scheduler tunable options: 每个I/O调度程序都有一组默认的可调选项,可以对这些选项进行调整,以帮助提高性能或公平共享您的特定用例。以下内核文档介绍了这些per-I/O调度程序可调选项:

deadline (and mq-deadline) deadline-iosched.txt

cfq cfq-iosched.txt

bfq bfq-iosched.txt

kyber kyber-iosched.txt

Best I/O scheduler to use
Different I/O requirements may benefit from changing from the Ubuntu distro default. A quick start guide to select a suitable I/O scheduler is below. The results are based on running 25 different synthetic I/O patterns generated using fio on ext4, xfs and btrfs with the various I/O schedulers using the 5.3 kernel. 不同的I/O需求可能会从Ubuntu发行版默认值的更改中受益。下面是选择合适I/O调度程序的快速入门指南。结果是基于在ext4、xfs和btrfs上使用fio生成的25种不同的合成I/O模式,以及使用5.3内核的各种I/O调度器。

SSD or NVME drives
It is worth noting that there is little difference in throughput between the mq-deadline/none/bfq I/O schedulers when using fast multi-queue SSD configurations or fast NVME devices. In these cases it may be preferable to use the ‘none’ I/O scheduler to reduce CPU overhead. 值得注意的是,当使用快速多队列SSD配置或快速NVME设备时,mq deadline/none/bfq I/O调度器之间的吞吐量差异很小。在这些情况下,最好使用“none” I/O调度程序来减少CPU开销。

HDD
Avoid using the none/noop I/O schedulers for a HDD as sorting requests on block addresses reduce the seek time latencies and neither of these I/O schedulers support this feature. mq-deadline has been shown to be advantageous for the more demanding server related I/O, however, desktop users may like to experiment with bfq as has been shown to load some applications faster. 避免对HDD使用none/noop I/O调度器,因为对块地址的排序请求可以减少寻道时间延迟,而且这两个I/O调度器都不支持此功能。mq deadline已被证明对于要求更高的服务器相关I/O是有利的,然而,桌面用户可能喜欢尝试bfq,因为它已被证明可以更快地加载一些应用程序。

Of course, your use-case may differ, the above are just suggestions to start with based on some synthetic tests. You may find other choices with adjustments to the I/O scheduler tunables produce better results. 当然,您的用例可能会有所不同,以上只是基于一些合成测试的建议。您可能会发现,通过调整I/O调度程序的可调参数,其他选择会产生更好的结果。

Linux I/O schedulers类型简介_Ubuntu_02


https://wiki.ubuntu.com/Kernel/Reference/IOSchedulers

标签:schedulers,简介,Ubuntu,调度,deadline,scheduler,Linux,requests
From: https://blog.51cto.com/feishujun/7934124

相关文章

  • Linux的Namespace,cgroup,chroot和docker的本质
    Linux的Namespace,cgroup,chroot和docker的本质-陈映峤的博客|LerkoBlog(chenyingqiao.github.io)chroot,即changerootdirectory(更改root目录)。在linux系统中,系统默认的目录结构都是以 /,即是以根(root)开始的。而在使用chroot之后,系统的目录结构将以指定的位......
  • Linux-expect(以交互形式输入命令,实现交互通信)
    1.expect简介expect是一种脚本语言,它能够代替人工实现与终端的交互,主要应用于执行命令和程序时,系统以交互形式要求输入指定字符串,实现交互通信。安装命令:yuminstallexpect; 2.expect使用场景(1)并根据预定标准回答其问题,回答“是”、“否”或将控制权交还给您(2)远程连接设备......
  • Linux-shell脚本使用ssh远程执行命令通过密码的方式登录
    1. sshpass简介sshpass是一个在非交互式ssh会话中自动输入密码的工具。它可以直接在命令行中指定密码,因此可以用于Shell脚本等自动化场景。在RedHat系统中,可以通过epel-release源安装sshpass。epel-release源是ExtraPackagesforEnterpriseLinux(EPEL)的缩写......
  • Linux-Shell 小数运算,四舍五入
    在shell中做小数运算,可以借助bc或者awk工具一、使用bc做小数运算,scale指定小数点位数1、加法运算(scale参数无效)#echo"5.999+5.001"|bc6.000#echo"5.111+5.1114"|bc10.2224运算结果小数点位数以加数中最大的为准 2、减法运算(scale参数无效)  同加法运算  运算......
  • 配置自定义服务为linux系统服务
    背景使用go语言写了一个测试环境部署上报的备份服务,以防因为主服务挂了影响部署操作。 想把这个backup服务设置了系统服务,如果因环境重启等异常,可以自动重启使用的环境的Centos71、首先需要创建一个systemdunit存储配置文件[Unit]Description=deployreportbackupse......
  • linux应急处置
    实战手把手教你,Linux服务器应急处置教学小编 CyberTorres 2023-10-0914:48 发表于广东收录于合集#linux1个#服务器1个#技术分享2个当你负责的服务器被黑了,怎么办?没遭遇过如此大风大浪的运维人员:哦,**!我该怎么办,点根香烟冷静一下。Wait!小编请您先切断网络,再......
  • 你是否还迷茫要不要学习Linux?
    近几年Linux这个词好像很流行,无论是现实工作中,还是在网络信息中均可以听到或者看到有关Linux相关的内容,可以说Linux无处不在。说到这,有人可能会问了,我对Linux比较感兴趣,但是没有接触过Linux,对它不了解,不知道是否适合自己,是否值得我花费时间和经历去深入学习,因此陷入一种比较迷茫的......
  • [ Linux ] 手动放行端口
    https://www.cnblogs.com/yeungchie/在云服务商的网页端操作防火墙会不生效,不清楚原因。可以用下面的命令来手动放行端口。iptables-tnat-IPREROUTING-ptcp--dport$port-mstate--stateNEW-jACCEPTiptables-PFORWARDACCEPT......
  • linux 内核 ---信号量(semaphore)
    信号量使用说明(1)定义信号量structsemaphoresem;(2)初始化信号量voidsema_init(structsemaphore*sem,intval);该函数初始化信号量,并设置信号量sem的值为val。(3)获得信号量externvoiddown(structsemaphore*sem);externint__must_checkdown_interruptible(st......
  • 手机使用linux
    手机使用linux调查方法termux使用手机linux分析手机是mate40使用内置linux需要获取root,华为关闭root获取网站还要刷机,麒麟9000还加了很多锁使用termux不需要root,直接虚拟一个linux就是额外占用一个系统准备手机华为mate40:安装termux能上外网(服了,还......