大网数据广告活动
服务器运维问答

What are front merges in I/O scheduling and how can I tune this parameter?

· 52CE 我爱测

My Linux uses the Deadline algorithm for I/O scheduling. One of the parameters is the front_merges parameter under /sys/block/sda/queue/iosched/front_merges . By default it is set to 1, which means front merges are likely to occu…

问题原文

原帖链接 · Ely · CC BY-SA 3.0

My Linux uses the Deadline algorithm for I/O scheduling. One of the parameters is the front_merges parameter under /sys/block/sda/queue/iosched/front_merges. By default it is set to 1, which means front merges are likely to occur. One can set it to 0 to gain a performance boost if don't expect front merges to occur.

  1. What are front merges exactly? Can someone depict this please?
  2. How do I know or test whether front merges occur on my system or not?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 3.0

The kernel documentation says it best:

Sometimes it happens that a request enters the io scheduler that is contiguous with a request that is already on the queue. Either it fits in the back of that request, or it fits at the front. That is called either a back merge candidate or a front merge candidate. Due to the way files are typically laid out, back merges are much more common than front merges. For some work loads, you may even know that it is a waste of time to spend any time attempting to front merge requests. Setting front_merges to 0 disables this functionality. Front merges may still occur due to the cached last_merge hint, but since that comes at basically 0 cost we leave that on. We simply disable the rbtree front sector lookup when the io scheduler merge function is called.

The reason front merges are uncommon is that writers typically do not write blocks to disk in reverse order.

Consider a process which does a simple sequential write of a new file containing two blocks. It first writes block 0, then writes block 1. When block 1 hits the queue, it is in the back of block 0, so the kernel does a back merge, then sends both blocks to the physical disk at the same time. This is the typical case.

To get a front merge, the process would first have to write block 1, then seek backward and write block 0. This isn't the typical case, though for some workloads it does happen (e.g. databases).

I wouldn't expect the change in performance to be that significant here, even with high I/O. You can test it both ways on your actual workload. If you aren't doing something disk intensive, then this isn't really important.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。