Re: [RFC] cfq: adapt slice to number of processes doing I/O

From: Corrado Zoccolo
Date: Thu Sep 03 2009 - 12:26:22 EST

Hi Jeff,

On Thu, Sep 3, 2009 at 3:01 PM, Jeff Moyer<jmoyer@xxxxxxxxxx> wrote:
> Corrado Zoccolo <czoccolo@xxxxxxxxx> writes:
>> When the number of processes performing I/O concurrently increases, Âa
>> fixed time slice per process will cause large latencies.
>> In the patch, if there are more than 3 processes performing concurrent
>> I/O, we scale the time slice down proportionally.
>> To safeguard sequential bandwidth, we impose a minimum time slice,
>> computed from cfq_slice_idle (the idea is that cfq_slice_idle
>> approximates the cost for a seek).
>> I performed two tests, on a rotational disk:
>> * 32 concurrent processes performing random reads
>> ** the bandwidth is improved from 466KB/s to 477KB/s
>> ** the maximum latency is reduced from 7.667s to 1.728
>> * 32 concurrent processes performing sequential reads
>> ** the bandwidth is reduced from 28093KB/s to 24393KB/s
>> ** the maximum latency is reduced from 3.781s to 1.115s
>> I expect numbers to be even better on SSDs, where the penalty to
>> disrupt sequential read is much less.
> Interesting approach. ÂI'm not sure what the benefits will be on SSDs,
> as the idling logic is disabled for them (when nonrot is set and they
> support ncq). ÂSee cfq_arm_slice_timer.

Yes, I know. Unfortunately, not all SSD devices have ncq.
Moreover, idling is disabled only for seeky processes, and the current
threshold to identify seeky processes is so high, that it rarely kicks

>> Signed-off-by: Corrado Zoccolo <czoccolo@gmail-com>
>> diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
>> index fd7080e..cff4ca8 100644
>> --- a/block/cfq-iosched.c
>> +++ b/block/cfq-iosched.c
>> @@ -306,7 +306,15 @@ cfq_prio_to_slice(struct cfq_data *cfqd, struct
>> cfq_queue *cfqq)
>> Âstatic inline void
>> Âcfq_set_prio_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
>> Â{
>> - Â Â Â cfqq->slice_end = cfq_prio_to_slice(cfqd, cfqq) + jiffies;
>> + Â Â Â unsigned low_slice = cfqd->cfq_slice_idle * (1 + cfq_cfqq_sync(cfqq));
>> + Â Â Â unsigned interested_queues = cfq_class_rt(cfqq) ?
>> cfqd->busy_rt_queues : cfqd->busy_queues;
> Either my mailer displayed this wrong, or yours wraps lines.
>> + Â Â Â unsigned slice = cfq_prio_to_slice(cfqd, cfqq);
>> + Â Â Â if (interested_queues > 3) {
>> + Â Â Â Â Â Â Â slice *= 3;
> How did you come to this magic number of 3, both for the number of
> competing tasks and the multiplier for the slice time? ÂDid you
> experiment with this number at all?

The number is quickly explained. The base slice is 100ms, and on the
mailing list it was mentioned that the latency becomes annoing for an
user when it is above 300ms.
This means that, up to 3 processes, the current thresholds are good,
and for more we have to scale.
This is good, because we don't change the behaviour unless we have
many competing processes.

>> + Â Â Â Â Â Â Â slice /= interested_queues;
> Of course you realize this could disable the idling logic completely,
> right? ÂI'll run this patch through some tests and let you know how it
> goes.
You already found that this is not the case.

Thanks for the interest
> Thanks!
> -Jeff


dott. Corrado Zoccolo mailto:czoccolo@xxxxxxxxx
PhD - Department of Computer Science - University of Pisa, Italy
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at