Reduce latencies for syncronous writes and high I/O priority requests in deadline IO scheduler
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
The attached patch, intended to reduce latencies for syncronous writes and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadline
The patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readers
* minimum batch timespan (time quantum): partners with fifo_batch to improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), therefore fifo_batch must be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.
I did few performance comparisons:
* HDD, ext3 partition with data=writeback, tiotest with 32 threads, each writing 80MB of data
** deadline-original
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.
| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 103.0 s | 24.848 MB/s | 10.6 % | 522.2 % | | Random Write 125 MBs | 98.8 s | 1.265 MB/s | -1.6 % | 16.1 % | | Read 2560 MBs | 166.2 s | 15.400 MB/s | 4.2 % | 82.7 % | | Random Read 125 MBs | 193.3 s | 0.647 MB/s | -0.8 % | 14.5 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.122 ms | 17922.920 ms | 0.07980 | 0.00061 | | Random Write | 0.599 ms | 1245.200 ms | 0.00000 | 0.00000 | | Read | 8.032 ms | 1125.759 ms | 0.00000 | 0.00000 | | Random Read | 181.968 ms | 972.657 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 10.044 ms | 17922.920 ms | 0.03804 | 0.00029 |
`--------------+-----------------+-----------------+----------+-----------'
** cfq (2.6.30-rc2)
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.
| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 132.4 s | 19.342 MB/s | 8.5 % | 400.4 % | | Random Write 125 MBs | 107.8 s | 1.159 MB/s | -1.6 % | 16.8 % | | Read 2560 MBs | 107.6 s | 23.788 MB/s | 5.4 % | 95.7 % | | Random Read 125 MBs | 158.4 s | 0.789 MB/s | 0.9 % | 7.7 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 5.362 ms | 21081.012 ms | 0.09811 | 0.00244 | | Random Write | 23.310 ms | 31865.095 ms | 0.13437 | 0.06250 | | Read | 5.048 ms | 3694.001 ms | 0.15167 | 0.00000 | | Random Read | 146.523 ms | 2880.409 ms | 0.52187 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 8.916 ms | 31865.095 ms | 0.13435 | 0.00262 |
`--------------+-----------------+-----------------+----------+-----------'
** deadline-patched
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.
| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 105.3 s | 24.301 MB/s | 10.5 % | 514.8 % | | Random Write 125 MBs | 95.9 s | 1.304 MB/s | -1.8 % | 17.3 % | | Read 2560 MBs | 165.1 s | 15.507 MB/s | 2.7 % | 61.9 % | | Random Read 125 MBs | 110.6 s | 1.130 MB/s | 0.8 % | 12.2 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.131 ms | 17456.831 ms | 0.08041 | 0.00275 | | Random Write | 2.780 ms | 5073.180 ms | 0.07500 | 0.00000 | | Read | 7.748 ms | 936.499 ms | 0.00000 | 0.00000 | | Random Read | 104.849 ms | 695.192 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 8.168 ms | 17456.831 ms | 0.04008 | 0.00131 |
`--------------+-----------------+-----------------+----------+-----------'
* SD card, nilfs2 partition, tiotest with 16 threads, each writing 80MB of data ** cfq(2.6.30-rc2)
Tiotest results for 16 concurrent io threads:
,----------------------------------------------------------------------.
| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 1280 MBs | 217.8 s | 5.878 MB/s | 3.7 % | 92.2 % | | Random Write 62 MBs | 18.2 s | 3.432 MB/s | -2.3 % | 28.7 % | | Read 1280 MBs | 114.7 s | 11.156 MB/s | 7.3 % | 76.6 % | | Random Read 62 MBs | 3.4 s | 18.615 MB/s | -5.4 % | 274.2 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 9.943 ms | 10223.581 ms | 0.14252 | 0.00488 | | Random Write | 12.287 ms | 5097.196 ms | 0.25625 | 0.00000 | | Read | 5.352 ms | 1550.162 ms | 0.00000 | 0.00000 | | Random Read | 3.051 ms | 1507.837 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 7.649 ms | 10223.581 ms | 0.07391 | 0.00233 |
`--------------+-----------------+-----------------+----------+-----------'
** deadline-patched:
Tiotest results for 16 concurrent io threads:
,----------------------------------------------------------------------.
| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 1280 MBs | 220.9 s | 5.794 MB/s | 4.0 % | 93.9 % | | Random Write 62 MBs | 20.5 s | 3.044 MB/s | -2.2 % | 24.9 % | | Read 1280 MBs | 113.2 s | 11.304 MB/s | 6.8 % | 72.8 % | | Random Read 62 MBs | 2.9 s | 21.896 MB/s | 5.1 % | 293.8 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 10.078 ms | 13303.036 ms | 0.14160 | 0.00031 | | Random Write | 14.350 ms | 5265.088 ms | 0.40000 | 0.00000 | | Read | 5.455 ms | 434.495 ms | 0.00000 | 0.00000 | | Random Read | 2.685 ms | 12.652 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 7.801 ms | 13303.036 ms | 0.07682 | 0.00015 |
`--------------+-----------------+-----------------+----------+-----------'
* fsync-tester results, on HDD, empty ext3 partition, mounted with data=writeback
** deadline-original:
fsync time: 0.7963
fsync time: 4.5914
fsync time: 4.2347
fsync time: 1.1670
fsync time: 0.8164
fsync time: 1.9783
fsync time: 4.9726
fsync time: 2.4929
fsync time: 2.5448
fsync time: 3.9627
** cfq 2.6.30-rc2
fsync time: 0.0288
fsync time: 0.0528
fsync time: 0.0299
fsync time: 0.0397
fsync time: 0.5720
fsync time: 0.0409
fsync time: 0.0876
fsync time: 0.0294
fsync time: 0.0485
** deadline-patched
fsync time: 0.0772
fsync time: 0.0381
fsync time: 0.0604
fsync time: 0.2923
fsync time: 0.2488
fsync time: 0.0924
fsync time: 0.0144
fsync time: 1.4824
fsync time: 0.0789
fsync time: 0.0565
fsync time: 0.0550
fsync time: 0.0421
** deadline-patched, ionice -c1:
fsync time: 0.2569
fsync time: 0.0500
fsync time: 0.0681
fsync time: 0.2863
fsync time: 0.0140
fsync time: 0.0171
fsync time: 0.1198
fsync time: 0.0530
fsync time: 0.0503
fsync time: 0.0462
fsync time: 0.0484
fsync time: 0.0328
fsync time: 0.0562
fsync time: 0.0451
fsync time: 0.0576
fsync time: 0.0444
fsync time: 0.0469
fsync time: 0.0368
fsync time: 0.2865
Corrado
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
block/deadline-iosched.c +232 -100
@@ -17,11 +17,12 @@/* * 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. */ +static const int rt_sync_expire =HZ /8 ;/* max time before a real-time sync operation (e.g. read for RT class process) is submitted. */ +static const int sync_expire =HZ /2 ;/* max time before a sync operation (e.g. read) is submitted. */ +static const int async_expire =5 *HZ ;/* ditto for async operations (e.g. writes), these limits are SOFT! */ +static const int async_starved =2 ;/* max times SYNC can starve ASYNC requests */ +static const int fifo_batch =16 ;/* min # of sequential requests treated as one by the above parameters. For throughput. */ +static const int time_quantum =HZ /10 ;/* min duration for a batch */ struct deadline_data {/*
@@ -31,27 +32,33 @@ struct deadline_data {/* * requests (deadline_rq s) are present on both sort_list and fifo_list */ -struct rb_root sort_list[2 ]; -struct list_head fifo_list[2 ]; +struct rb_root sort_list[2 ];/* READ, WRITE */ +struct list_head fifo_list[3 ];/* 0=ASYNC (or IDLE), 1=SYNC (or RT ASYNC), 2=RT SYNC */ /* -* next in sort order. read, write or both are NULL +* next in sort order. */ -struct request *next_rq[2 ]; +struct request *next_rq;unsigned int batching;/* number of sequential requests made */ -sector_t last_sector;/* head position */ unsigned int starved;/* times reads have starved writes */ /* * settings that change how the i/o scheduler behaves */ -int fifo_expire[2 ]; +int fifo_expire[3 ]; +int time_quantum;int fifo_batch; -int writes_starved; +int async_starved;int front_merges; + +/* +current batch data & stats +*/ +int cur_batch_prio; +unsigned long cur_batch_start; }; -static void deadline_move_request (struct deadline_data *,struct request *); +static void deadline_move_request (struct deadline_data *,struct request *,int nonrot);static inline struct rb_root *deadline_rb_root (struct deadline_data *dd,struct request *rq)
@@ -63,7 +70,7 @@ deadline_rb_root(struct deadline_data *dd, struct request *rq)* get the request after `rq' in sector-sorted order */ static inline struct request * -deadline_latter_request (struct request *rq) +deadline_next_request (struct request *rq) {struct rb_node *node =rb_next (&rq->rb_node);
@@ -73,27 +80,118 @@ deadline_latter_request(struct request *rq)return NULL ; } +/* +* get the request before `rq' in sector-sorted order +*/ +static inline struct request * +deadline_prev_request (struct request *rq) +{ +struct rb_node *node =rb_prev (&rq->rb_node); + +if (node) +return rb_entry_rq (node); + +return NULL ; +} +static void -deadline_add_rq_rb (struct deadline_data *dd,struct request *rq) +deadline_add_rq_rb (struct deadline_data *dd,struct request *rq,int nonrot) {struct rb_root *root =deadline_rb_root (dd, rq);struct request *__alias;while (unlikely (__alias =elv_rb_add (root, rq))) -deadline_move_request (dd, __alias); +deadline_move_request (dd, __alias, nonrot); }static inline void deadline_del_rq_rb (struct deadline_data *dd,struct request *rq) { -const int data_dir =rq_data_dir (rq); - -if (dd->next_rq[data_dir] == rq) - dd->next_rq[data_dir] =deadline_latter_request (rq); +if (dd->next_rq == rq) + dd->next_rq =deadline_next_request (rq);elv_rb_del (deadline_rb_root (dd, rq), rq); } +static void +list_add_timesorted (struct list_head *q,struct request *rq) +{ +struct list_head *entry; +int stop_flags =REQ_SOFTBARRIER |REQ_HARDBARRIER |REQ_STARTED ; +list_for_each_prev (entry, q) { +struct request *pos =list_entry_rq (entry); +if (pos->cmd_flags & stop_flags) +break ; +if (rq_fifo_time (rq) >rq_fifo_time (pos)) +break ; +if (rq_fifo_time (rq) ==rq_fifo_time (pos) && + rq->sector >= pos->sector) +break ; + } +list_add (&rq->queuelist, entry); +} + +static int ioprio_lub (unsigned short aprio,unsigned short bprio) +{ +unsigned short aclass =IOPRIO_PRIO_CLASS (aprio); +unsigned short bclass =IOPRIO_PRIO_CLASS (bprio); + +if (aclass ==IOPRIO_CLASS_NONE ) +return bprio; +if (bclass ==IOPRIO_CLASS_NONE ) +return aprio; + +if (aclass == bclass) +return min (aprio, bprio); +if (aclass > bclass) +return bprio; +else +return aprio; +} + +static void +deadline_merge_prio_data (struct request_queue *q,struct request *rq) +{ +struct task_struct *tsk = current; +struct io_context *ioc =get_io_context (GFP_ATOMIC ,q->node); +int ioprio_class =IOPRIO_CLASS_NONE ; +int ioprio =IOPRIO_NORM ; + +if (ioc) { + ioprio_class =task_ioprio_class (ioc); + } + +switch (ioprio_class) { +default : +printk (KERN_ERR "deadline: bad prio %x\n" , ioprio_class); +case IOPRIO_CLASS_NONE : +/* +* no prio set, inherit CPU scheduling settings +*/ + ioprio =task_nice_ioprio (tsk); + ioprio_class =task_nice_ioclass (tsk); +break ; +case IOPRIO_CLASS_RT : +case IOPRIO_CLASS_BE : + ioprio =task_ioprio (ioc); +break ; +case IOPRIO_CLASS_IDLE : + ioprio =7 ; +break ; + } + + ioprio=IOPRIO_PRIO_VALUE (ioprio_class,ioprio); + rq->ioprio=ioprio_lub (rq->ioprio,ioprio); +} + +static int +deadline_compute_request_priority (struct request *req) +{ +unsigned short ioprio_class=IOPRIO_PRIO_CLASS (req_get_ioprio (req)); +return (ioprio_class!=IOPRIO_CLASS_IDLE )* + (!!rq_is_sync (req) + (rq_data_dir (req)==READ )*(ioprio_class==IOPRIO_CLASS_RT )); +} +/* * add rq to rbtree and fifo */
@@ -101,15 +199,17 @@ static void deadline_add_request(struct request_queue *q, struct request *rq) { struct deadline_data *dd = q->elevator->elevator_data; -const int data_dir =rq_data_dir (rq); -deadline_add_rq_rb (dd, rq); +deadline_merge_prio_data (q,rq); +deadline_add_rq_rb (dd, rq,blk_queue_nonrot (q));/* -* set expire time and add to fifo list +* set request creation time and add to fifo list */ -rq_set_fifo_time (rq, jiffies + dd->fifo_expire[data_dir]); -list_add_tail (&rq->queuelist, &dd->fifo_list[data_dir]); + +rq_set_fifo_time (rq, jiffies); + +list_add_timesorted (&dd->fifo_list[deadline_compute_request_priority (rq)],rq); }/*
@@ -157,14 +257,16 @@ static void deadline_merged_request(struct request_queue *q, struct request *req, int type) {struct deadline_data *dd = q->elevator->elevator_data; -/* * if the merge was a front merge, we need to reposition request */ if (type ==ELEVATOR_FRONT_MERGE ) {elv_rb_del (deadline_rb_root (dd, req), req); -deadline_add_rq_rb (dd, req); +deadline_add_rq_rb (dd, req,blk_queue_nonrot (q)); } + +deadline_merge_prio_data (q,req); + } static void
@@ -172,7 +274,7 @@ deadline_merged_requests(struct request_queue *q, struct request *req, struct request *next) {/* -* if next expires before rq, assign its expire time to rq +* request that cannot idle. if next expires before rq, assign its expire time to rq * and move into next position (next will be deleted) in fifo */ if (!list_empty (&req->queuelist) && !list_empty (&next->queuelist)) {
@@ -204,15 +306,33 @@ deadline_move_to_dispatch(struct deadline_data *dd, struct request *rq)* move an entry to dispatch queue */ static void -deadline_move_request (struct deadline_data *dd,struct request *rq) +deadline_move_request (struct deadline_data *dd,struct request *rq,int nonrot) {const int data_dir =rq_data_dir (rq); + dd->next_rq =NULL ; + +if (data_dir !=READ || !nonrot) { +int max_search = dd->fifo_batch; +/* for rot devices, or writes on non-rot, requests are dispatched in disk order */ + dd->next_rq = rq; +/* try to get requests of at least the same priority as current one */ +while (max_search-- && (dd->next_rq =deadline_next_request (dd->next_rq)) && dd->cur_batch_prio>deadline_compute_request_priority (dd->next_rq)); +if (!max_search || !dd->next_rq) {// did not get a next of the same priority, demote batch to lower, and continue in disk order + dd->next_rq =deadline_next_request (rq); +if (dd->next_rq) dd->cur_batch_prio =deadline_compute_request_priority (dd->next_rq); + } - dd->next_rq[READ ] =NULL ; - dd->next_rq[WRITE ] =NULL ; - dd->next_rq[data_dir] =deadline_latter_request (rq); - - dd->last_sector =rq_end_sector (rq); + }else {/* nonrot && data_dir==READ : requests are dispatched in deadline order */ +struct list_head *entry; +list_for_each (entry, &dd->fifo_list[dd->cur_batch_prio]) { +struct request *pos =list_entry_rq (entry); +if (pos==rq)continue ; +if (rq_data_dir (pos)==data_dir) {/* find same direction (always READ) */ + dd->next_rq = pos; +break ; + } + } + }/* * take it off the sort and fifo list, move
@@ -222,20 +342,16 @@ deadline_move_request(struct deadline_data *dd, struct request *rq) }/* -* deadline_check_fifo returns 0 if there are no expired requests on the fifo, -* 1 otherwise. Requires !list_empty(&dd->fifo_list[data_dir]) +* deadline_check_fifo returns 0 if there are no expired requests on the fifo for given priority, +* 1 otherwise. Requires !list_empty(&dd->fifo_list[prio]) */ -static inline int deadline_check_fifo (struct deadline_data *dd,int ddir) +static inline int deadline_check_request (struct deadline_data *dd,unsigned prio) { -struct request *rq =rq_entry_fifo (dd->fifo_list[ddir].next); - +BUG_ON (list_empty (&dd->fifo_list[prio]));/* -* rq is expired! +* deadline is expired! */ -if (time_after (jiffies,rq_fifo_time (rq))) -return 1 ; - -return 0 ; +return time_after (jiffies, dd->fifo_expire[prio] +rq_fifo_time (rq_entry_fifo (dd->fifo_list[prio].next))); }/*
@@ -245,36 +361,31 @@ static inline int deadline_check_fifo(struct deadline_data *dd, int ddir)static int deadline_dispatch_requests (struct request_queue *q,int force) {struct deadline_data *dd = q->elevator->elevator_data; -const int reads = !list_empty (&dd->fifo_list[READ ]); -const int writes = !list_empty (&dd->fifo_list[WRITE ]); -struct request *rq; -int data_dir; +int rt_ = !list_empty (&dd->fifo_list[2 ]); +int sync_ = !list_empty (&dd->fifo_list[1 ]); +int async_ = !list_empty (&dd->fifo_list[0 ]); +struct request *rq = dd->next_rq; +int request_prio = dd->cur_batch_prio; -/* -* batches are currently reads XOR writes -*/ -if (dd->next_rq[WRITE ]) - rq = dd->next_rq[WRITE ]; -else - rq = dd->next_rq[READ ]; - -if (rq && dd->batching < dd->fifo_batch) +if (rq && (dd->batching < dd->fifo_batch || jiffies-dd->cur_batch_start < dd->time_quantum)) {/* we have a next request are still entitled to batch */ goto dispatch_request; + }/* * at this point we are not running a batch. select the appropriate * data direction (read / write) */ -if (reads) { -BUG_ON (RB_EMPTY_ROOT (&dd->sort_list[READ ])); - -if (writes && (dd->starved++ >= dd->writes_starved)) - goto dispatch_writes; - - data_dir =READ ; +if (rt_) { + request_prio =2 ; + goto dispatch_find_request; + } +if (sync_) { +if (async_ && (dd->starved++ >= dd->async_starved)) + goto dispatch_async; + request_prio =1 ; goto dispatch_find_request; }
@@ -282,37 +393,44 @@ static int deadline_dispatch_requests(struct request_queue *q, int force)* there are either no reads or writes have been starved */ -if (writes) { -dispatch_writes: -BUG_ON (RB_EMPTY_ROOT (&dd->sort_list[WRITE ])); - +if (async_) { +dispatch_async: dd->starved =0 ; - - data_dir =WRITE ; - + request_prio =0 ; goto dispatch_find_request; } + dd->cur_batch_start=jiffies; + dd->batching =0 ;return 0 ; dispatch_find_request: +/* -* we are not running a batch, find best request for selected data_dir +* we are not running a batch, find best request for selected request_prio */ -if (deadline_check_fifo (dd, data_dir) || !dd->next_rq[data_dir]) { +if (!dd->next_rq || + dd->cur_batch_prio < request_prio || +deadline_check_request (dd, request_prio)) {/* -* A deadline has expired, the last request was in the other -* direction, or we have run out of higher-sectored requests. -* Start again from the request with the earliest expiry time. +* A deadline has expired, the previous batch had a lower priority, +* or we have run out of higher-sectored requests. +* Start again (a bit before) the request with the earliest expiry time. */ - rq =rq_entry_fifo (dd->fifo_list[data_dir].next); +struct request * nrq =rq_entry_fifo (dd->fifo_list[request_prio].next); +int batch = dd->fifo_batch/3 ; + rq=nrq; +while (batch-- && (nrq =deadline_prev_request (nrq))) +if (request_prio<=deadline_compute_request_priority (nrq)) rq = nrq; }else {/* -* The last req was the same dir and we have a next request in +* The last batch was same or higher priority and we have a next request in * sort order. No expired requests so continue on from here. */ - rq = dd->next_rq[data_dir]; + rq = dd->next_rq; } + dd->cur_batch_prio = request_prio; + dd->cur_batch_start = jiffies; dd->batching =0 ;
@@ -320,26 +438,29 @@ dispatch_request:/* * rq is the selected appropriate request. */ - dd->batching++; -deadline_move_request (dd, rq); + dd->batching++; +deadline_move_request (dd, rq,blk_queue_nonrot (q));return 1 ; }static int deadline_queue_empty (struct request_queue *q) {struct deadline_data *dd = q->elevator->elevator_data; - -return list_empty (&dd->fifo_list[WRITE ]) - &&list_empty (&dd->fifo_list[READ ]); +return list_empty (&dd->fifo_list[0 ]) + &&list_empty (&dd->fifo_list[1 ]) + &&list_empty (&dd->fifo_list[2 ]); } + +static void deadline_exit_queue (struct elevator_queue *e) {struct deadline_data *dd = e->elevator_data; -BUG_ON (!list_empty (&dd->fifo_list[READ ])); -BUG_ON (!list_empty (&dd->fifo_list[WRITE ])); +BUG_ON (!list_empty (&dd->fifo_list[0 ])); +BUG_ON (!list_empty (&dd->fifo_list[1 ])); +BUG_ON (!list_empty (&dd->fifo_list[2 ]));kfree (dd); }
@@ -355,13 +476,16 @@ static void *deadline_init_queue(struct request_queue *q)if (!dd)return NULL ; -INIT_LIST_HEAD (&dd->fifo_list[READ ]); -INIT_LIST_HEAD (&dd->fifo_list[WRITE ]); +INIT_LIST_HEAD (&dd->fifo_list[0 ]); +INIT_LIST_HEAD (&dd->fifo_list[1 ]); +INIT_LIST_HEAD (&dd->fifo_list[2 ]); dd->sort_list[READ ] =RB_ROOT ; dd->sort_list[WRITE ] =RB_ROOT ; - dd->fifo_expire[READ ] = read_expire; - dd->fifo_expire[WRITE ] = write_expire; - dd->writes_starved = writes_starved; + dd->fifo_expire[0 ] = async_expire; + dd->fifo_expire[1 ] = sync_expire; + dd->fifo_expire[2 ] = rt_sync_expire; + dd->time_quantum = time_quantum; + dd->async_starved = async_starved; dd->front_merges =1 ; dd->fifo_batch = fifo_batch;return dd;
@@ -395,9 +519,12 @@ static ssize_t __FUNC(struct elevator_queue *e, char *page) \ __data =jiffies_to_msecs (__data); \return deadline_var_show (__data, (page)); \ } -SHOW_FUNCTION (deadline_read_expire_show, dd->fifo_expire[READ ],1 ); -SHOW_FUNCTION (deadline_write_expire_show, dd->fifo_expire[WRITE ],1 ); -SHOW_FUNCTION (deadline_writes_starved_show, dd->writes_starved,0 ); +SHOW_FUNCTION (deadline_async_expire_show, dd->fifo_expire[0 ],1 ); +SHOW_FUNCTION (deadline_sync_expire_show, dd->fifo_expire[1 ],1 ); +SHOW_FUNCTION (deadline_rt_sync_expire_show, dd->fifo_expire[2 ],1 ); +SHOW_FUNCTION (deadline_time_quantum_show, dd->time_quantum,1 ); + +SHOW_FUNCTION (deadline_async_starved_show, dd->async_starved,0 );SHOW_FUNCTION (deadline_front_merges_show, dd->front_merges,0 );SHOW_FUNCTION (deadline_fifo_batch_show, dd->fifo_batch,0 );#undef SHOW_FUNCTION
@@ -418,9 +545,12 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count) *(__PTR) = __data; \return ret; \ } -STORE_FUNCTION (deadline_read_expire_store, &dd->fifo_expire[READ ],0 ,INT_MAX ,1 ); -STORE_FUNCTION (deadline_write_expire_store, &dd->fifo_expire[WRITE ],0 ,INT_MAX ,1 ); -STORE_FUNCTION (deadline_writes_starved_store, &dd->writes_starved,INT_MIN ,INT_MAX ,0 ); +STORE_FUNCTION (deadline_async_expire_store, &dd->fifo_expire[0 ],0 ,INT_MAX ,1 ); +STORE_FUNCTION (deadline_sync_expire_store, &dd->fifo_expire[1 ],0 ,INT_MAX ,1 ); +STORE_FUNCTION (deadline_rt_sync_expire_store, &dd->fifo_expire[2 ],0 ,INT_MAX ,1 ); +STORE_FUNCTION (deadline_time_quantum_store, &dd->time_quantum,0 ,INT_MAX ,1 ); + +STORE_FUNCTION (deadline_async_starved_store, &dd->async_starved,INT_MIN ,INT_MAX ,0 );STORE_FUNCTION (deadline_front_merges_store, &dd->front_merges,0 ,1 ,0 );STORE_FUNCTION (deadline_fifo_batch_store, &dd->fifo_batch,0 ,INT_MAX ,0 );#undef STORE_FUNCTION
@@ -430,9 +560,11 @@ STORE_FUNCTION(deadline_fifo_batch_store, &dd->fifo_batch, 0, INT_MAX, 0); deadline_##name##_store)static struct elv_fs_entry deadline_attrs[] = { -DD_ATTR (read_expire), -DD_ATTR (write_expire), -DD_ATTR (writes_starved), +DD_ATTR (async_expire), +DD_ATTR (sync_expire), +DD_ATTR (rt_sync_expire), +DD_ATTR (time_quantum), +DD_ATTR (async_starved),DD_ATTR (front_merges),DD_ATTR (fifo_batch), __ATTR_NULL
Quoted 4 lines · Corrado Zoccolo
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
Quoted 9 lines
The attached patch, intended to reduce latencies for syncronous writes and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadline
numbers are impressive.
do you observe better latencies in normal desktop usage as well?
ciao,
Signature · 3 lines
Paolo http://paolo.ciarrocchi.googlepages.com/ http://mypage.vodafone.it/
Quoted 13 lines · Corrado Zoccolo
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
The attached patch, intended to reduce latencies for syncronous writes and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadline
Quoted 3 lines
The patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readers
Danger danger... I smell nasty heuristics.
Quoted 10 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.
This is a huge patch, I'm not going to be reviewing this. Make this a patchset, each doing that little change separately. Then it's easier to review, and much easier to pick the parts that can go in directly and leave the ones that either need more work or are not going be merged out.
Quoted 3 lines
I did few performance comparisons:
* HDD, ext3 partition with data=writeback, tiotest with 32 threads, each writing 80MB of data
It doesn't seem to make a whole lot of difference, does it?
Quoted 42 lines
** deadline-original
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 103.0 s | 24.848 MB/s | 10.6 % | 522.2 % | | Random Write 125 MBs | 98.8 s | 1.265 MB/s | -1.6 % | 16.1 % | | Read 2560 MBs | 166.2 s | 15.400 MB/s | 4.2 % | 82.7 % | | Random Read 125 MBs | 193.3 s | 0.647 MB/s | -0.8 % | 14.5 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.122 ms | 17922.920 ms | 0.07980 | 0.00061 | | Random Write | 0.599 ms | 1245.200 ms | 0.00000 | 0.00000 | | Read | 8.032 ms | 1125.759 ms | 0.00000 | 0.00000 | | Random Read | 181.968 ms | 972.657 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 10.044 ms | 17922.920 ms | 0.03804 | 0.00029 |`--------------+-----------------+-----------------+----------+-----------'
** deadline-patched
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 105.3 s | 24.301 MB/s | 10.5 % | 514.8 % | | Random Write 125 MBs | 95.9 s | 1.304 MB/s | -1.8 % | 17.3 % | | Read 2560 MBs | 165.1 s | 15.507 MB/s | 2.7 % | 61.9 % | | Random Read 125 MBs | 110.6 s | 1.130 MB/s | 0.8 % | 12.2 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.131 ms | 17456.831 ms | 0.08041 | 0.00275 | | Random Write | 2.780 ms | 5073.180 ms | 0.07500 | 0.00000 | | Read | 7.748 ms | 936.499 ms | 0.00000 | 0.00000 | | Random Read | 104.849 ms | 695.192 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 8.168 ms | 17456.831 ms | 0.04008 | 0.00131 |
Quoted 1 line
`--------------+-----------------+-----------------+----------+-----------'
Main difference here seems to be random read performance, the rest are pretty close and could just be noise. Random write is much worse, from a latency view point. Is this just one run, or did you average several?
For something like this, you also need to consider workloads that consist of processes with different IO patterns running at the same time. With this tiotest run, you only test sequential readers competing, then random readers, etc.
So, please, split the big patch into lots of little separate pieces. Benchmark each one separately, so they each carry their own justification.
Quoted 28 lines
* fsync-tester results, on HDD, empty ext3 partition, mounted with data=writeback
** deadline-original:
fsync time: 0.7963
fsync time: 4.5914
fsync time: 4.2347
fsync time: 1.1670
fsync time: 0.8164
fsync time: 1.9783
fsync time: 4.9726
fsync time: 2.4929
fsync time: 2.5448
fsync time: 3.9627
** cfq 2.6.30-rc2
fsync time: 0.0288
fsync time: 0.0528
fsync time: 0.0299
fsync time: 0.0397
fsync time: 0.5720
fsync time: 0.0409
fsync time: 0.0876
fsync time: 0.0294
fsync time: 0.0485
** deadline-patched
fsync time: 0.0772
fsync time: 0.0381
fsync time: 0.0604
fsync time: 0.2923
Quoted 8 lines
fsync time: 0.2488
fsync time: 0.0924
fsync time: 0.0144
fsync time: 1.4824
fsync time: 0.0789
fsync time: 0.0565
fsync time: 0.0550
fsync time: 0.0421
At least this test looks a lot better!
Signature · 1 line
Jens Axboe
Hi Jens,
Quoted 6 lines · Jens Axboe
Quoted 3 lines · Corrado Zoccolo
The patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readersDanger danger... I smell nasty heuristics.
Ok, I wanted to sneak this heuristic in :), but probably I can abridge it from the initial submission.
The fact is that many people around are using noop scheduler for SSDs, to get the ultimate preformance out of their hardware, and I wanted to give them a better alternative. CFQ doesn't honor non-rotational flag when tag-queuing is not supported, so it will not be an alternative in such cases.
Quoted 12 lines
Quoted 11 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.
Quoted 6 lines
This is a huge patch, I'm not going to be reviewing this. Make this a patchset, each doing that little change separately. Then it's easier to review, and much easier to pick the parts that can go in directly and leave the ones that either need more work or are not going be merged out.
Ok.
I think I can split it into:
* add new heuristics (so those can be evaluated independently of the read/write vs. sync/async)
* read/write becomes sync/async
* add iopriorities
Quoted 5 lines
Quoted 3 lines
I did few performance comparisons:
* HDD, ext3 partition with data=writeback, tiotest with 32 threads, each writing 80MB of dataIt doesn't seem to make a whole lot of difference, does it?
The intent is not to boost throughput, but to reduce sync latency. The heuristics were added to avoid throughput regression.
Quoted 3 lines
Main difference here seems to be random read performance, the rest are pretty close and could just be noise. Random write is much worse, from a latency view point. Is this just one run, or did you average several?
The random writes issued by tio-test are async writes, so the latency is not an issue, and having higher latencies here actually help in improving throughput.
Quoted 5 lines
For something like this, you also need to consider workloads that consist of processes with different IO patterns running at the same time. With this tiotest run, you only test sequential readers competing, then random readers, etc.
Sure. Do you have any suggestion?
I have an other workload, that is the boot of my netbook, on which the patched ioscheduler saves 1s out of 12s.
All other IOschedulers, including noop, perform equally worse (for noop, I think I lose on writes).
Quoted 3 lines
So, please, split the big patch into lots of little separate pieces. Benchmark each one separately, so they each carry their own justification.
Does a theoretical proof of unfairness also matter, for the fifo_batch/3 backjump?
Quoted 3 lines
Quoted 1 line
* fsync-tester results, on HDD, empty ext3 partition, mounted with
At least this test looks a lot better!
This is why the subject says "reducing latencies ..." :) Maybe I should have started the mails with this test, instead of the other ones showing that there wasn't regression for throughput (that in principle could happen when trying to reduce latencies).
Thanks,
Corrado
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
Quoted 5 lines · Corrado Zoccolo
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
The attached patch, intended to reduce latencies for syncronous writes
Can be achieved by switching to sync/async rather than read/write. No one has shown results where this makes an improvement. Let us know if you have a good example.
Quoted 11 lines
and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadlineThe patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readers
This might be a good idea. Can you make this a separate patch? Is there a good reason not to do the same for writes?
Quoted 10 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.
I don't like the rest of it. I use deadline because it's a simple, no surprises, no bullshit scheduler with reasonably good performance in all situations. Is there some reason why CFQ won't work for you?
Quoted 174 lines
I did few performance comparisons:
* HDD, ext3 partition with data=writeback, tiotest with 32 threads, each writing 80MB of data** deadline-original
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 103.0 s | 24.848 MB/s | 10.6 % | 522.2 % | | Random Write 125 MBs | 98.8 s | 1.265 MB/s | -1.6 % | 16.1 % | | Read 2560 MBs | 166.2 s | 15.400 MB/s | 4.2 % | 82.7 % | | Random Read 125 MBs | 193.3 s | 0.647 MB/s | -0.8 % | 14.5 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.122 ms | 17922.920 ms | 0.07980 | 0.00061 | | Random Write | 0.599 ms | 1245.200 ms | 0.00000 | 0.00000 | | Read | 8.032 ms | 1125.759 ms | 0.00000 | 0.00000 | | Random Read | 181.968 ms | 972.657 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 10.044 ms | 17922.920 ms | 0.03804 | 0.00029 |`--------------+-----------------+-----------------+----------+-----------'
** cfq (2.6.30-rc2)
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 132.4 s | 19.342 MB/s | 8.5 % | 400.4 % | | Random Write 125 MBs | 107.8 s | 1.159 MB/s | -1.6 % | 16.8 % | | Read 2560 MBs | 107.6 s | 23.788 MB/s | 5.4 % | 95.7 % | | Random Read 125 MBs | 158.4 s | 0.789 MB/s | 0.9 % | 7.7 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 5.362 ms | 21081.012 ms | 0.09811 | 0.00244 | | Random Write | 23.310 ms | 31865.095 ms | 0.13437 | 0.06250 | | Read | 5.048 ms | 3694.001 ms | 0.15167 | 0.00000 | | Random Read | 146.523 ms | 2880.409 ms | 0.52187 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 8.916 ms | 31865.095 ms | 0.13435 | 0.00262 |`--------------+-----------------+-----------------+----------+-----------'
** deadline-patched
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 105.3 s | 24.301 MB/s | 10.5 % | 514.8 % | | Random Write 125 MBs | 95.9 s | 1.304 MB/s | -1.8 % | 17.3 % | | Read 2560 MBs | 165.1 s | 15.507 MB/s | 2.7 % | 61.9 % | | Random Read 125 MBs | 110.6 s | 1.130 MB/s | 0.8 % | 12.2 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.131 ms | 17456.831 ms | 0.08041 | 0.00275 | | Random Write | 2.780 ms | 5073.180 ms | 0.07500 | 0.00000 | | Read | 7.748 ms | 936.499 ms | 0.00000 | 0.00000 | | Random Read | 104.849 ms | 695.192 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 8.168 ms | 17456.831 ms | 0.04008 | 0.00131 |`--------------+-----------------+-----------------+----------+-----------'
* SD card, nilfs2 partition, tiotest with 16 threads, each writing 80MB of data ** cfq(2.6.30-rc2)
Tiotest results for 16 concurrent io threads:
,----------------------------------------------------------------------.| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 1280 MBs | 217.8 s | 5.878 MB/s | 3.7 % | 92.2 % | | Random Write 62 MBs | 18.2 s | 3.432 MB/s | -2.3 % | 28.7 % | | Read 1280 MBs | 114.7 s | 11.156 MB/s | 7.3 % | 76.6 % | | Random Read 62 MBs | 3.4 s | 18.615 MB/s | -5.4 % | 274.2 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 9.943 ms | 10223.581 ms | 0.14252 | 0.00488 | | Random Write | 12.287 ms | 5097.196 ms | 0.25625 | 0.00000 | | Read | 5.352 ms | 1550.162 ms | 0.00000 | 0.00000 | | Random Read | 3.051 ms | 1507.837 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 7.649 ms | 10223.581 ms | 0.07391 | 0.00233 |`--------------+-----------------+-----------------+----------+-----------'
** deadline-patched:
Tiotest results for 16 concurrent io threads:
,----------------------------------------------------------------------.| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 1280 MBs | 220.9 s | 5.794 MB/s | 4.0 % | 93.9 % | | Random Write 62 MBs | 20.5 s | 3.044 MB/s | -2.2 % | 24.9 % | | Read 1280 MBs | 113.2 s | 11.304 MB/s | 6.8 % | 72.8 % | | Random Read 62 MBs | 2.9 s | 21.896 MB/s | 5.1 % | 293.8 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 10.078 ms | 13303.036 ms | 0.14160 | 0.00031 | | Random Write | 14.350 ms | 5265.088 ms | 0.40000 | 0.00000 | | Read | 5.455 ms | 434.495 ms | 0.00000 | 0.00000 | | Random Read | 2.685 ms | 12.652 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 7.801 ms | 13303.036 ms | 0.07682 | 0.00015 |`--------------+-----------------+-----------------+----------+-----------'
* fsync-tester results, on HDD, empty ext3 partition, mounted with data=writeback
** deadline-original:
fsync time: 0.7963
fsync time: 4.5914
fsync time: 4.2347
fsync time: 1.1670
fsync time: 0.8164
fsync time: 1.9783
fsync time: 4.9726
fsync time: 2.4929
fsync time: 2.5448
fsync time: 3.9627
** cfq 2.6.30-rc2
fsync time: 0.0288
fsync time: 0.0528
fsync time: 0.0299
fsync time: 0.0397
fsync time: 0.5720
fsync time: 0.0409
fsync time: 0.0876
fsync time: 0.0294
fsync time: 0.0485
** deadline-patched
fsync time: 0.0772
fsync time: 0.0381
fsync time: 0.0604
fsync time: 0.2923
fsync time: 0.2488
fsync time: 0.0924
fsync time: 0.0144
fsync time: 1.4824
fsync time: 0.0789
fsync time: 0.0565
fsync time: 0.0550
fsync time: 0.0421
** deadline-patched, ionice -c1:
fsync time: 0.2569
fsync time: 0.0500
fsync time: 0.0681
fsync time: 0.2863
fsync time: 0.0140
fsync time: 0.0171
fsync time: 0.1198
fsync time: 0.0530
fsync time: 0.0503
fsync time: 0.0462
fsync time: 0.0484
fsync time: 0.0328
fsync time: 0.0562
fsync time: 0.0451
fsync time: 0.0576
fsync time: 0.0444
fsync time: 0.0469
fsync time: 0.0368
fsync time: 0.2865Corrado
Quoted 37 lines · Aaron Carroll
Quoted 5 lines · Corrado Zoccolo
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
The attached patch, intended to reduce latencies for syncronous writesCan be achieved by switching to sync/async rather than read/write. No one has shown results where this makes an improvement. Let us know if you have a good example.
Quoted 11 lines
and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadlineThe patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readersThis might be a good idea. Can you make this a separate patch? Is there a good reason not to do the same for writes?
Quoted 10 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.
Quoted 3 lines
I don't like the rest of it. I use deadline because it's a simple, no surprises, no bullshit scheduler with reasonably good performance in all situations. Is there some reason why CFQ won't work for you?
Fully agree with that, deadline is not going to be changed radically. Doing sync/async instead of read/write would indeed likely bring the latency results down alone, what impact the rest has is unknown.
If CFQ performs poorly for some situations, we fix that.
Signature · 1 line
Jens Axboe
Quoted 10 lines · Aaron Carroll
Quoted 5 lines · Corrado Zoccolo
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
The attached patch, intended to reduce latencies for syncronous writesCan be achieved by switching to sync/async rather than read/write. No one has shown results where this makes an improvement. Let us know if you have a good example.
Yes, this is exactly what my patch does, and the numbers for fsync-tester are much better than baseline deadline, almost comparable with cfq.
Quoted 9 lines
Quoted 9 lines
and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadline
Quoted 5 lines
Quoted 3 lines
The patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readersThis might be a good idea.
I think Jens doesn't like it very much.
Quoted 1 line
Can you make this a separate patch?
I have an earlier attempt, much simpler, at:
http://lkml.indiana.edu/hypermail/linux/kernel/0904.1/00667.html
Quoted 1 line
Is there a good reason not to do the same for writes?
Well, in that case you could just use noop.
I found that this scheme outperforms noop. Random writes, in fact, perform quite bad on most SSDs (unless you use a logging FS like nilfs2, that transforms them into sequential writes), so having all the deadline ioscheduler machinery to merge write requests is much better. As I said, my patched IO scheduler outperforms noop on my normal usage.
Quoted 11 lines
Quoted 10 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.
Quoted 3 lines
I don't like the rest of it. I use deadline because it's a simple, no surprises, no bullshit scheduler with reasonably good performance in all situations. Is there some reason why CFQ won't work for you?
I actually like CFQ, and use it almost everywhere, and switch to deadline only when submitting an heavy-duty workload (having a SysRq combination to switch I/O schedulers could sometimes be very handy).
However, on SSDs it's not optimal, so I'm developing this to overcome those limitations.
In the meantime, I wanted to overcome also deadline limitations, i.e. the high latencies on fsync/fdatasync.
Corrado
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
Hi Corrado,
Quoted 7 lines · Corrado Zoccolo
Quoted 6 lines · Aaron Carroll
Quoted 5 lines · Corrado Zoccolo
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
The attached patch, intended to reduce latencies for syncronous writes
Quoted 7 lines
Quoted 3 lines
Can be achieved by switching to sync/async rather than read/write. No one has shown results where this makes an improvement. Let us know if you have a good example.
Yes, this is exactly what my patch does, and the numbers for fsync-tester are much better than baseline deadline, almost comparable with cfq.
The patch does a bunch of other things too. I can't tell what is due to the read/write -> sync/async change, and what is due to the rest of it.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadline
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
The patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readersThis might be a good idea.
I think Jens doesn't like it very much.
Let's convince him :)
I think a nice way to do this would be to make fifo_batch=1 the default for nonrot devices. Of course this will affect writes too...
One problem here is the definition of nonrot. E.g. if H/W RAID drivers
start setting that flag, it will kill performance. Sorting is important for arrays of rotational disks.
Quoted 5 lines
Quoted 1 line
Can you make this a separate patch?
I have an earlier attempt, much simpler, at:
http://lkml.indiana.edu/hypermail/linux/kernel/0904.1/00667.htmlQuoted 1 line
Is there a good reason not to do the same for writes?
Well, in that case you could just use noop.
Noop doesn't merge as well as deadline, nor does is provide read/write differentiation. Is there a performance/QoS argument for not doing it?
Quoted 6 lines
I found that this scheme outperforms noop. Random writes, in fact, perform quite bad on most SSDs (unless you use a logging FS like nilfs2, that transforms them into sequential writes), so having all the deadline ioscheduler machinery to merge write requests is much better. As I said, my patched IO scheduler outperforms noop on my normal usage.
You still get the merging... we are only talking about the issue order here.
Quoted 14 lines
Quoted 10 lines
Quoted 10 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.Quoted 3 lines
I don't like the rest of it. I use deadline because it's a simple, no surprises, no bullshit scheduler with reasonably good performance in all situations. Is there some reason why CFQ won't work for you?
Quoted 6 lines
I actually like CFQ, and use it almost everywhere, and switch to deadline only when submitting an heavy-duty workload (having a SysRq combination to switch I/O schedulers could sometimes be very handy).
However, on SSDs it's not optimal, so I'm developing this to overcome those limitations.
Is this due to the stall on each batch switch?
Quoted 2 lines
In the meantime, I wanted to overcome also deadline limitations, i.e. the high latencies on fsync/fdatasync.
Did you try dropping the expiry times and/or batch size?
-- Aaron
Quoted 3 lines
Corrado
Hi Aaron
Quoted 19 lines · Aaron Carroll
Hi Corrado,
Quoted 16 lines · Corrado Zoccolo
Quoted 12 lines · Aaron Carroll
Quoted 6 lines · Corrado Zoccolo
Hi,
deadline I/O scheduler currently classifies all I/O requests in only 2 classes, reads (always considered high priority) and writes (always lower).
The attached patch, intended to reduce latencies for syncronous writesCan be achieved by switching to sync/async rather than read/write. No one has shown results where this makes an improvement. Let us know if you have a good example.
Quoted 6 lines
Quoted 3 lines
Yes, this is exactly what my patch does, and the numbers for fsync-tester are much better than baseline deadline, almost comparable with cfq.
The patch does a bunch of other things too. I can't tell what is due to the read/write -> sync/async change, and what is due to the rest of it.
Ok, I got it. I'm splitting it in smaller patches.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
and high I/O priority requests, introduces more levels of priorities:
* real time reads: highest priority and shortest deadline, can starve other levels
* syncronous operations (either best effort reads or RT/BE writes), mid priority, starvation for lower level is prevented as usual
* asyncronous operations (async writes and all IDLE class requests), lowest priority and longest deadlineThe patch also introduces some new heuristics:
* for non-rotational devices, reads (within a given priority level) are issued in FIFO order, to improve the latency perceived by readers
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
This might be a good idea.
I think Jens doesn't like it very much.
Let's convince him :)
I think a nice way to do this would be to make fifo_batch=1 the default for nonrot devices. Of course this will affect writes too...
Fifo_batch has various implications, concerning also the alternation between reads and writes.
Moreover, too low numbers also negatively affect merging. In deadline, often merging on writeback requests happens because the scheduler is handling unrelated requests for some time, so incoming requests have time to accumulate.
Quoted 5 lines
One problem here is the definition of nonrot. E.g. if H/W RAID drivers start setting that flag, it will kill performance. Sorting is important for arrays of rotational disks.
The flag should have a well defined semantics.
In RAID, I think it could be defined for the aggregated disk, while single disks will be rotational or not depending on the technology. This could work very well, since each disk will sort only its requests, and the scheduler will not waste time on other disk requests.
A random read workload with reads smaller than the RAID stripe will shine with this.
Clearly, for writes, since multiple disks are touched, the sorting must be performed at the aggregated disk level to have some opportunity of reducing data transfers: this corresponds to what my patch does.
Quoted 11 lines
Quoted 8 lines
Quoted 1 line
Can you make this a separate patch?
I have an earlier attempt, much simpler, at:
http://lkml.indiana.edu/hypermail/linux/kernel/0904.1/00667.htmlQuoted 2 lines
Is there a good reason not to do the same for writes?
Well, in that case you could just use noop.
Noop doesn't merge as well as deadline, nor does is provide read/write differentiation. Is there a performance/QoS argument for not doing it?
I think only experimentation can tell. But the RAID argument above could make a case.
Quoted 10 lines
Quoted 6 lines
I found that this scheme outperforms noop. Random writes, in fact, perform quite bad on most SSDs (unless you use a logging FS like nilfs2, that transforms them into sequential writes), so having all the deadline ioscheduler machinery to merge write requests is much better. As I said, my patched IO scheduler outperforms noop on my normal usage.
You still get the merging... we are only talking about the issue order here.
Ditto, more experimentation is needed.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.I don't like the rest of it. I use deadline because it's a simple, no surprises, no bullshit scheduler with reasonably good performance in all situations. Is there some reason why CFQ won't work for you?
Quoted 8 lines
Quoted 6 lines
I actually like CFQ, and use it almost everywhere, and switch to deadline only when submitting an heavy-duty workload (having a SysRq combination to switch I/O schedulers could sometimes be very handy).
However, on SSDs it's not optimal, so I'm developing this to overcome those limitations.
Is this due to the stall on each batch switch?
Possibly (CFQ is too complex to start hacking with it without some experience on something simpler).
AFAIK, it should be disabled when ronrot=1, but actually only if the device supports tag queuing.
I think, however, that the whole machinery of CFQ is too heavy for non-rotational devices, where a simple fifo scheme, adjusted with priorities, can achieve fair handling of requests.
Quoted 5 lines
Quoted 3 lines
In the meantime, I wanted to overcome also deadline limitations, i.e. the high latencies on fsync/fdatasync.
Did you try dropping the expiry times and/or batch size?
Yes. Expiry times are soft, so often they are not satisfied. Dropping batch size will cause bandwidth drop, causing expiry times to miss more often due to longer queues (I'm speaking of rotational devices here, since the latencies affect also them).
Quoted 9 lines
-- Aaron
Quoted 3 lines
Corrado
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
Quoted 15 lines · Corrado Zoccolo
Quoted 11 lines
Quoted 10 lines
* minimum batch timespan (time quantum): partners with
fifo_batchto improve throughput, by sending more consecutive requests together. A given number of requests will not always take the same time (due to amount of seek needed), thereforefifo_batchmust be tuned for worst cases, while in best cases, having longer batches would give a throughput boost.
* batch start request is chosen fifo_batch/3 requests before the expired one, to improve fairness for requests with lower start sector, that otherwise have higher probability to miss a deadline than mid-sector requests.Quoted 3 lines
I don't like the rest of it. I use deadline because it's a simple, no surprises, no bullshit scheduler with reasonably good performance in all situations. Is there some reason why CFQ won't work for you?
Quoted 6 lines
I actually like CFQ, and use it almost everywhere, and switch to deadline only when submitting an heavy-duty workload (having a SysRq combination to switch I/O schedulers could sometimes be very handy).
However, on SSDs it's not optimal, so I'm developing this to overcome those limitations.
I find your solution quite confusing - the statement is that it CFQ isn't optimal on SSD, so you modify deadline? ;-)
Most of the "CFQ doesn't work well on SSD" statements are mostly wrong. Now, you seem to have done some testing, so when you say that you probably have actually done some testing that tells you that this is the case. But lets attempt to fix that issue, then!
One thing you pointed out is that CFQ doesn't treat the device as a "real" SSD unless it does queueing. This is very much on purpose, for two reasons:
1) I have never seen a non-queueing SSD that actually performs well for reads-vs-write situations, so CFQ still does idling for those.
2) It's a problem that is going away. SSD that are coming out today and in the future WILL definitely do queuing. We can attribute most of the crap behaviour to the lacking jmicron flash controller, which also has a crappy SATA interface.
What I am worried about in the future is even faster SSD devices. CFQ is already down a percent or two when we are doing 100k iops and such, this problem will only get worse. So I'm very much interested in speeding up CFQ for such devices, which I think will mainly be slimming down the IO path and bypassing much of the (unneeded) complexity for them. The last thing I want is to have to tell people to use deadline or noop on SSD devices.
Quoted 2 lines
In the meantime, I wanted to overcome also deadline limitations, i.e. the high latencies on fsync/fdatasync.
This is very much something you could pull out of the patchset and we could include without much questioning.
Signature · 1 line
Jens Axboe
Quoted 2 lines · Jens Axboe
I find your solution quite confusing - the statement is that it CFQ isn't optimal on SSD, so you modify deadline? ;-)
Well, I find CFQ too confusing to start with, so I chose a simpler one. If I can prove something with deadline, maybe you will decide to implement it also on CFQ ;)
Quoted 6 lines
Most of the "CFQ doesn't work well on SSD" statements are mostly wrong. Now, you seem to have done some testing, so when you say that you probably have actually done some testing that tells you that this is the case. But lets attempt to fix that issue, then!
Quoted 6 lines
One thing you pointed out is that CFQ doesn't treat the device as a "real" SSD unless it does queueing. This is very much on purpose, for two reasons:
1) I have never seen a non-queueing SSD that actually performs well for reads-vs-write situations, so CFQ still does idling for those.
Does CFQ idle only when switching between reads and writes, or even when switching between reads from one process, and reads from an other?
I think I'll have to instrument CFQ a bit to understand how it works. Is there a better way instead of scattering printks all around?
Quoted 4 lines
2) It's a problem that is going away. SSD that are coming out today and in the future WILL definitely do queuing. We can attribute most of the crap behaviour to the lacking jmicron flash controller, which also has a crappy SATA interface.
I think SD cards will still be around a lot, and I don't expect them to have queuing, so some support for them might still be needed.
Quoted 8 lines
What I am worried about in the future is even faster SSD devices. CFQ is already down a percent or two when we are doing 100k iops and such, this problem will only get worse. So I'm very much interested in speeding up CFQ for such devices, which I think will mainly be slimming down the IO path and bypassing much of the (unneeded) complexity for them. The last thing I want is to have to tell people to use deadline or noop on SSD devices.
Totally agree. Having the main IOscheduler perform good on most scenarios is surely needed.
But this could be achieved in various ways.
What if the main IO scheduler had in his toolbox various strategies, and could switch between them based on the workload or type of hardware?
FIFO scheduling for reads could be one such strategy, used only when the conditions are good for it.
An other possibility is to use auto-tuning strategies, but those are more difficult to devise and test.
Quoted 6 lines
Quoted 2 lines
In the meantime, I wanted to overcome also deadline limitations, i.e. the high latencies on fsync/fdatasync.
This is very much something you could pull out of the patchset and we could include without much questioning.
Ok, this is the first patch of the series, and contains code cleanup needed before changing read/write to sync/async. No behavioral change is introduced by this patch.
I found where the random read performance is gained, but I didn't include in this patch, because it require sync/async separation to not negatively impact sync write latencies.
If the following new code, that replicates existing behaviour:
if (!dd->next_rq
|| rq_data_dir(dd->next_rq) != data_dir
|| deadline_check_fifo(dd, data_dir)) {
/*
* A deadline has expired, the last request was in the other
* direction, or we have run out of higher-sectored requests.
is changed to:
if (!dd->next_rq
|| rq_data_dir(dd->next_rq) > data_dir
|| deadline_check_fifo(dd, data_dir)) {
/*
* A deadline has expired, the last request was lessimportant (where WRITE is less important than READ),
* or we have run out of higher-sectored requests.
you get both higher random read throughput and higher write latencies.
Corrado
Quoted 4 lines
--
Jens Axboe
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
Quoted 4 lines · Corrado Zoccolo
Ok, this is the first patch of the series, and contains code cleanup needed before changing read/write to sync/async. No behavioral change is introduced by this patch.
And this one is the second patch, that changes read/write to sync vs. async. fsync-tester results,with
while : ; do time sh -c "dd if=/dev/zero of=bigfile bs=8M
count=256 ; sync; rm bigfile"; done:
running in the background
./fsync-tester
fsync time: 0.6383
fsync time: 0.1835
fsync time: 0.1744
fsync time: 0.1103
fsync time: 0.1535
fsync time: 0.1545
fsync time: 0.1491
fsync time: 0.1524
fsync time: 0.1609
fsync time: 0.1168
fsync time: 0.1458
fsync time: 0.1328
fsync time: 0.1655
fsync time: 0.1731
fsync time: 0.1356
fsync time: 0.1746
fsync time: 0.1166
fsync time: 0.1609
fsync time: 0.1370
fsync time: 0.1379
fsync time: 0.2096
fsync time: 0.1438
fsync time: 0.1652
fsync time: 0.1612
fsync time: 0.1438
compared with original deadline:
fsync time: 0.7963
fsync time: 4.5914
fsync time: 4.2347
fsync time: 1.1670
fsync time: 0.8164
fsync time: 1.9783
fsync time: 4.9726
fsync time: 2.4929
fsync time: 2.5448
fsync time: 3.9627
Usual tio-test, 32 threads 80Mb each:
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.
| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 103.6 s | 24.705 MB/s | 9.7 % | 495.6 % | | Random Write 125 MBs | 95.9 s | 1.304 MB/s | -1.9 % | 23.8 % | | Read 2560 MBs | 164.3 s | 15.580 MB/s | 3.5 % | 70.1 % | | Random Read 125 MBs | 129.7 s | 0.964 MB/s | -0.0 % | 16.2 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.040 ms | 8949.999 ms | 0.07614 | 0.00000 | | Random Write | 1.252 ms | 5439.023 ms | 0.03125 | 0.00000 | | Read | 7.920 ms | 792.899 ms | 0.00000 | 0.00000 | | Random Read | 123.807 ms | 910.263 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 8.613 ms | 8949.999 ms | 0.03703 | 0.00000 |
`--------------+-----------------+-----------------+----------+-----------'
compared with original deadline:
Tiotest results for 32 concurrent io threads:
,----------------------------------------------------------------------.
| Item | Time | Rate | Usr CPU | Sys CPU | +-----------------------+----------+--------------+----------+---------+ | Write 2560 MBs | 103.0 s | 24.848 MB/s | 10.6 % | 522.2 % | | Random Write 125 MBs | 98.8 s | 1.265 MB/s | -1.6 % | 16.1 % | | Read 2560 MBs | 166.2 s | 15.400 MB/s | 4.2 % | 82.7 % | | Random Read 125 MBs | 193.3 s | 0.647 MB/s | -0.8 % | 14.5 % | `----------------------------------------------------------------------' Tiotest latency results: ,-------------------------------------------------------------------------. | Item | Average latency | Maximum latency | % >2 sec | % >10 sec | +--------------+-----------------+-----------------+----------+-----------+ | Write | 4.122 ms | 17922.920 ms | 0.07980 | 0.00061 | | Random Write | 0.599 ms | 1245.200 ms | 0.00000 | 0.00000 | | Read | 8.032 ms | 1125.759 ms | 0.00000 | 0.00000 | | Random Read | 181.968 ms | 972.657 ms | 0.00000 | 0.00000 | |--------------+-----------------+-----------------+----------+-----------| | Total | 10.044 ms | 17922.920 ms | 0.03804 | 0.00029 |
`--------------+-----------------+-----------------+----------+-----------'
We see the improvement on random read (not as pronounced as with full set of heuristics, but still noticeable) and smaller increase on random write latency, but this will not harm, since now we have distinction between sync vs async reads.
I can test which of the other heuristics will provide the other few % of improvements on random read if you are interested. Otherwise, I'm more inclined on submitting an other patch to add io-priorities to this series.
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
Hi Jens,
I found fio, a very handy and complete tool for block I/O performance testing (kudos to the author), and started doing some thorough testing for the patch, since I couldn't tune tiotest behaviour, and I had only a surface understanding of what was going on.
The test configuration is attached for reference. Each test is run after dropping the caches. The suffix .2 or .3 means the value for {writes,async}_starved tunable.
My findings are interesting:
* there is a definite improvement for many readers performing random reads and one sequential writer (this was the one I think tiotest was showing, due to unclear separation -i.e. no fsync- between tiotest phases). This workload simulates boot for a single disk machine, with random reads that represent fault-ins for binaries and libraries, and sequential writes that represent log updates.
* the improvement is not present if the number of readers is small (e.g. 4). It gets performance similar to original deadline, that is far below cfq. The problem appears to be caused by the unfairness for low-numbered sectors, and happens only when the random readers have overlapping reading regions. Let's assume 4 readers as in my test. The workload evolution will be: a read batch is started, from the request that is first in FIFO. The probability that the batch starts at the first read in disk order is 1/4, and the probability that it will be first in next second is 7/24 (assuming the first reader doesn't post a new request yet). This means there is 11/24 of probability that we need more than 2 batches to service all initial read requests (and then we will service the starved writer: increasing writes_starved in fact improves the reader bw). If the reading regions overlap, after the writer is serviced, the FIFO will still be randomly ordered, so the same pattern will repeat.
A perfect scheduler, instead, for each batch in which fewer than fifo_batch requests are available, should schedule all the read requests available, i.e. start from the first in disk order instead of the first in FIFO order (unless a deadline is expired). This allows the readers to progress much faster. Do you want me to test such heuristic?
** I think there is also an other theoretical bad case in deadline behaviour, i.e. when all deadlines expire. In that case, it switches to complete FIFO batch scheduling. In this case, instead. scheduling all requests in disk order will allow for a faster recovery. Do you think we should handle also this case?
* I think that now that we differentiate between sync and async writes, we can painlessly increase the async_starved tunable. This will provide better performance for mixed workloads as random readers mixed with sequential writer. In particular, the 32 readers/1writer test shows impressive performance, where full write bandwidth is achieved, while reader bandwidth outperforms all other schedulers, including cfq (that instead completely starve the writer).
* on my machine, there is a regression on sequential write (2 parallel sequential writers, instead, give better performance, and 1 seq writer mixed with many random readers max out the write bandwidth). Interestingly, this regression disappears when I spread some printks around. It is therefore a timing issue, that causes less merges to happen (I think this can be fixed allowing async writes to be scheduled only after an initial delay):
# run with printks #
seqwrite: (g=0): rw=write, bs=4K-4K/4K-4K, ioengine=psync, iodepth=1 Starting 1 process
Jobs: 1 (f=1): [F] [100.0% done] [ 0/ 0 kb/s] [eta 00m:00s]
seqwrite: (groupid=0, jobs=1): err= 0: pid=4838
write: io=1010MiB, bw=30967KiB/s, iops=7560, runt= 34193msec
clat (usec): min=7, max=4274K, avg=114.53, stdev=13822.22
cpu : usr=1.44%, sys=9.47%, ctx=1299, majf=0, minf=154
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued r/w: total=0/258510, short=0/0
lat (usec): 10=45.00%, 20=52.36%, 50=2.18%, 100=0.05%, 250=0.32%
lat (usec): 500=0.03%, 750=0.01%, 1000=0.01%
lat (msec): 2=0.01%, 4=0.01%, 10=0.01%, 100=0.01%, 250=0.02%
lat (msec): 500=0.01%, 2000=0.01%, >=2000=0.01%Run status group 0 (all jobs):
WRITE: io=1010MiB, aggrb=30967KiB/s, minb=30967KiB/s,
maxb=30967KiB/s, mint=34193msec, maxt=34193msec
Disk stats (read/write):
sda: ios=35/8113, merge=0/250415, ticks=2619/4277418,
in_queue=4280032, util=96.52%
# run without printks #
seqwrite: (g=0): rw=write, bs=4K-4K/4K-4K, ioengine=psync, iodepth=1
Starting 1 process
Jobs: 1 (f=1): [F] [100.0% done] [ 0/ 0 kb/s] [eta 00m:00s]
seqwrite: (groupid=0, jobs=1): err= 0: pid=5311
write: io=897076KiB, bw=26726KiB/s, iops=6524, runt= 34371msec
clat (usec): min=7, max=1801K, avg=132.11, stdev=6407.61
cpu : usr=1.14%, sys=7.84%, ctx=1272, majf=0, minf=318
IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued r/w: total=0/224269, short=0/0
lat (usec): 10=49.04%, 20=49.05%, 50=1.17%, 100=0.07%, 250=0.51%
lat (usec): 500=0.02%, 750=0.01%, 1000=0.01%
lat (msec): 2=0.01%, 4=0.02%, 10=0.01%, 20=0.01%, 50=0.01%
lat (msec): 100=0.05%, 250=0.03%, 500=0.01%, 2000=0.01%Run status group 0 (all jobs):
WRITE: io=897076KiB, aggrb=26726KiB/s, minb=26726KiB/s,
maxb=26726KiB/s, mint=34371msec, maxt=34371msec
Disk stats (read/write):
sda: ios=218/7041, merge=0/217243, ticks=16638/4254061,
in_queue=4270696, util=98.92%
Corrado
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------
Quoted 1 line · Corrado Zoccolo
* on my machine, there is a regression on sequential write
I found that the regression was just an artifact of my testing (the test partition was almost full, and the written files were re-created at each test, resulting in non-uniform fragmentation across tests). Changing the test to preallocate also the write file made the test more repeateable, with the result that patched deadline and original perform equal.
Here is the last patch of the series, that add I/O priority support to deadline. All requests are sorted into 3 levels of priorities :
* 0: async reads/writes, and all Idle class requests
* 1: sync Best Effort reads/writes, and sync Real Time writes
* 2: Real Time reads.
Aaron, I found your previous attempt at modifying deadline to use sync/async instead of read/write.
My approach is slightly different, since I changed only the fifos to respect the new scheme, while the RB trees are still partitioned as reads vs writes.
Since the RB trees are used for merging and for batch formation, having the RB trees as in original deadline should guarantee the same success rate for merging, and allow to create longer batches that span across priority levels, when requests on a given priority level are too few to fully utilize the disk bandwidth (this is usually the case for writes, where we have few sync writes to the journal, mixed with lots of async writes to the data).
Corrado
Signature · 5 lines
__________________________________________________________________________ dott. Corrado Zoccolo mailto:[email protected] PhD - Department of Computer Science - University of Pisa, Italy --------------------------------------------------------------------------