On Mon 01 Mar 2021 01:11:55 PM CET, Peter Lieven <p...@kamp.de> wrote: > Why we talk about throttling I still do not understand the following part in > util/throttle.c function throttle_compute_wait > > > if (!bkt->max) { > /* If bkt->max is 0 we still want to allow short bursts of I/O > * from the guest, otherwise every other request will be throttled > * and performance will suffer considerably. */ > bucket_size = (double) bkt->avg / 10; > burst_bucket_size = 0; > } else { > /* If we have a burst limit then we have to wait until all I/O > * at burst rate has finished before throttling to bkt->avg */ > bucket_size = bkt->max * bkt->burst_length; > burst_bucket_size = (double) bkt->max / 10; > } > > > Why burst_bucket_size = bkt->max / 10? > > From what I understand it should be bkt->max. Otherwise we compare the > "extra" against a tenth of the bucket capacity
1) bkt->max is the burst rate in bytes/second [*] 2) burst_bucket_size is used to decide when to start throttling (you can see the code at the end of throttle_compute_wait()). The important thing is that burst_bucket_size does not actually have an influence on the actual burst rate. Increasing that value is not going to make the I/O faster, it just means that I/O will be throttled later. Once the I/O is throttled, the actual burst rate is define by how quick the burst bucket leaks (see throttle_leak_bucket()). The higher burst_bucket_size is, the longer we allow the guest to exceed the maximum rate. So we divide blk->max by 10 in order to allow the guest to perform 100ms' worth of I/O without being throttled. See the commit message of 0770a7a6466cc2dbf4ac91841173ad4488e1fbc7 for more details. Berto