ablog

不器用で落着きのない技術者のメモ

LinuxのI/OスケジューラによるI/O要求のマージ

アプリケーションから発行されたI/OはカーネルのI/Oスケジューラでマージ(まとめる)やソート(並び替え)が行われるというのは本で読んで知っていたが、ソースコードは見たことがなかったのでちょっとだけ覗いてみた。以下は deadline の個所

  • block/deadline-iosched.c
/*
 * See Documentation/block/deadline-iosched.txt
 */
static const int read_expire = HZ / 2;  /* max time before a read is submitted. */
static const int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */
static const int writes_starved = 2;    /* max times reads can starve a write */
static const int fifo_batch = 16;       /* # of sequential requests treated as one
				     by the above parameters. For throughput. */
  • Documentation/block/deadline-iosched.txt
fifo_batch	(number of requests)
----------

Requests are grouped into ``batches'' of a particular data direction (read or
write) which are serviced in increasing sector order.  To limit extra seeking,
deadline expiries are only checked between batches.  fifo_batch controls the
maximum number of requests per batch.

This parameter tunes the balance between per-request latency and aggregate
throughput.  When low latency is the primary concern, smaller is better (where
a value of 1 yields first-come first-served behaviour).  Increasing fifo_batch
generally improves throughput, at the cost of latency variation.