From: Max Reitz <mreitz@redhat.com>
To: Sascha Silbe <silbe@linux.vnet.ibm.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Jeff Cody <jcody@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/1] Improve block job rate limiting for small bandwidth values
Date: Tue, 5 Jul 2016 20:27:46 +0200 [thread overview]
Message-ID: <5785923c-48c2-41a7-b1db-ac279abac058@redhat.com> (raw)
In-Reply-To: <8760skklhh.fsf@oc4731375738.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3035 bytes --]
On 05.07.2016 20:06, Sascha Silbe wrote:
> Dear Max,
>
> Max Reitz <mreitz@redhat.com> writes:
>
>> [ Good signature by key: 0x58B381CE2DC89CF99730EE643BB14202E838ACAD ]
>
> Feel free to drop by if you happen to be in the Stuttgart area some
> time. PGP key signing, a beverage of your choice and optionally some
> chatting about qemu and related topics. :)
Happens rarely, but does happen. The Red Hat office I'm associated with
actually is in Stuttgart, but most of the time I live (and work) 500 km
away from it.
>> On 04.07.2016 16:30, Sascha Silbe wrote:
>>> Max Reitz <mreitz@redhat.com> writes:
> [...]
> [include/qemu/ratelimit.h]
>>>>> static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
>>>>> {
>>>>> int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
>>>>> + uint64_t delay_slices;
>>>>>
>>>>> - if (limit->next_slice_time < now) {
>>>>> - limit->next_slice_time = now + limit->slice_ns;
>>>>> + assert(limit->slice_quota && limit->slice_ns);
>>>>> +
>>>>> + if (limit->slice_end_time < now) {
>>>>> + /* Previous, possibly extended, time slice finished; reset the
>>>>> + * accounting. */
>>>>> + limit->slice_start_time = now;
>>>>> + limit->slice_end_time = now + limit->slice_ns;
>>>>> limit->dispatched = 0;
>>>>> }
>>>>> - if (limit->dispatched == 0 || limit->dispatched + n <= limit->slice_quota) {
>>>>> - limit->dispatched += n;
>>>>> +
>>>>> + limit->dispatched += n;
>>>>> + if (limit->dispatched < limit->slice_quota) {
>>>>
>>>> Nitpick: This should probably stay <=.
>>>
>>> This is a subtle edge case. Previously, when limit->dispatched ==
>>> limit->slice_quota, we returned 0 so that the _current_ request (which
>>> is still within quota) wouldn't be delayed. Now, we return a delay so
>>> that the _next_ request (which would be over quota) will be delayed.
>>
>> Hm, but that depends on the size of the next request. Of course, if we
>> get limit->dispatched == limit->slice_quota we know for sure that we
>> need to delay the next request. But if we get limit->dispatched ==
>> limit->slice_quota - 1... Then we probably also have to delay it, but we
>> don't know for sure.
>
> No matter where exactly we draw the line, due to the way the block job
> rate limiting works (fixed size time slices, fixed size requests) there
> will always be cases where we're off the target rate quite a bit, in one
> or the other direction.
>
> For rate limits where we can send an integer number of chunks per time
> slice (i.e. some MiB/s sized value), the "<" condition is probably
> better. We'll send out a couple of chunks that exactly match the quota,
> then sleep for the rest of the time slice. If we'd use "<=", we'd send
> out one extra chunk before we start sleeping.
>
> But I don't care much either way, "<=" is fine with me, too.
Well, and above all, we'll hopefully replace all of this in 2.8 anyway.
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]
next prev parent reply other threads:[~2016-07-05 18:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 15:28 [Qemu-devel] [PATCH 0/1] Fix iotests race condition by fixing block job rate limiting Sascha Silbe
2016-06-28 15:28 ` [Qemu-devel] [PATCH 1/1] Improve block job rate limiting for small bandwidth values Sascha Silbe
2016-07-02 13:22 ` Max Reitz
2016-07-04 14:30 ` Sascha Silbe
2016-07-05 16:56 ` Max Reitz
2016-07-05 18:06 ` Sascha Silbe
2016-07-05 18:27 ` Max Reitz [this message]
2016-07-05 18:28 ` [Qemu-devel] [PATCH 0/1] Fix iotests race condition by fixing block job rate limiting Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5785923c-48c2-41a7-b1db-ac279abac058@redhat.com \
--to=mreitz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=silbe@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).