All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergio Lopez <slp@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org,
	"mreitz@redhat.com" <mreitz@redhat.com>,
	"fam@euphon.net" <fam@euphon.net>,
	Paolo Bonzini <pbonzini@redhat.com>,
	jusual@mail.ru
Subject: Re: [Qemu-devel] Combining synchronous and asynchronous IO
Date: Thu, 11 Apr 2019 13:41:42 +0200	[thread overview]
Message-ID: <87pnps3h1l.fsf@redhat.com> (raw)
In-Reply-To: <20190315155010.GG5368@linux.fritz.box>

[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]


Kevin Wolf <kwolf@redhat.com> writes:

> Am 15.03.2019 um 16:33 hat Sergio Lopez geschrieben:
>> 
>> Stefan Hajnoczi writes:
>> 
>> > On Thu, Mar 14, 2019 at 06:31:34PM +0100, Sergio Lopez wrote:
>> >> Our current AIO path does a great job at unloading the work from the VM,
>> >> and combined with IOThreads provides a good performance in most
>> >> scenarios. But it also comes with its costs, in both a longer execution
>> >> path and the need of the intervention of the scheduler at various
>> >> points.
>> >> 
>> >> There's one particular workload that suffers from this cost, and that's
>> >> when you have just 1 or 2 cores on the Guest issuing synchronous
>> >> requests. This happens to be a pretty common workload for some DBs and,
>> >> in a general sense, on small VMs.
>> >> 
>> >> I did a quick'n'dirty implementation on top of virtio-blk to get some
>> >> numbers. This comes from a VM with 4 CPUs running on an idle server,
>> >> with a secondary virtio-blk disk backed by a null_blk device with a
>> >> simulated latency of 30us.
>> >
>> > Can you describe the implementation in more detail?  Does "synchronous"
>> > mean that hw/block/virtio_blk.c makes a blocking preadv()/pwritev() call
>> > instead of calling blk_aio_preadv/pwritev()?  If so, then you are also
>> > bypassing the QEMU block layer (coroutines, request tracking, etc) and
>> > that might explain some of the latency.
>> 
>> The first implementation, the one I've used for getting these numbers,
>> it's just preadv/pwrite from virtio_blk.c, as you correctly guessed. I
>> know it's unfair, but I wanted to take a look at the best possible
>> scenario, and then measure the cost of the other layers.
>> 
>> I'm working now on writing non-coroutine counterparts for
>> blk_co_[preadv|pwrite], so we have SIO without bypassing the block layer.
>
> Maybe try to keep the change local to file-posix.c? I think you would
> only have to modify raw_thread_pool_submit() so that it doesn't go
> through the thread pool, but just calls func directly.
>
> I don't think avoiding coroutines is possible without bypassing the block
> layer altogether because everything is really expecting to be run in
> coroutine context.

Turns out what I initially thought was a cost induced by the AIO nature
of our block layer, it's actually a bug in which polling mode works
against aio=threads, delaying the execution of the request completions.

This has been fixed by Paolo's "aio-posix: ensure poll mode is left when
aio_notify is called":

https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01426.html

So we can throw away the idea of combining synchronous and asynchronous
requests, as it doesn't provide a significant improvement that would
justify the added complexity.

Thanks,
Sergio.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Sergio Lopez <slp@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: "fam@euphon.net" <fam@euphon.net>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org,
	"mreitz@redhat.com" <mreitz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	jusual@mail.ru
Subject: Re: [Qemu-devel] Combining synchronous and asynchronous IO
Date: Thu, 11 Apr 2019 13:41:42 +0200	[thread overview]
Message-ID: <87pnps3h1l.fsf@redhat.com> (raw)
Message-ID: <20190411114142.v9q--JYCje46rIKoCHe1_AR4jLuFTSfRtGV8_OHGrLU@z> (raw)
In-Reply-To: <20190315155010.GG5368@linux.fritz.box>

[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]


Kevin Wolf <kwolf@redhat.com> writes:

> Am 15.03.2019 um 16:33 hat Sergio Lopez geschrieben:
>> 
>> Stefan Hajnoczi writes:
>> 
>> > On Thu, Mar 14, 2019 at 06:31:34PM +0100, Sergio Lopez wrote:
>> >> Our current AIO path does a great job at unloading the work from the VM,
>> >> and combined with IOThreads provides a good performance in most
>> >> scenarios. But it also comes with its costs, in both a longer execution
>> >> path and the need of the intervention of the scheduler at various
>> >> points.
>> >> 
>> >> There's one particular workload that suffers from this cost, and that's
>> >> when you have just 1 or 2 cores on the Guest issuing synchronous
>> >> requests. This happens to be a pretty common workload for some DBs and,
>> >> in a general sense, on small VMs.
>> >> 
>> >> I did a quick'n'dirty implementation on top of virtio-blk to get some
>> >> numbers. This comes from a VM with 4 CPUs running on an idle server,
>> >> with a secondary virtio-blk disk backed by a null_blk device with a
>> >> simulated latency of 30us.
>> >
>> > Can you describe the implementation in more detail?  Does "synchronous"
>> > mean that hw/block/virtio_blk.c makes a blocking preadv()/pwritev() call
>> > instead of calling blk_aio_preadv/pwritev()?  If so, then you are also
>> > bypassing the QEMU block layer (coroutines, request tracking, etc) and
>> > that might explain some of the latency.
>> 
>> The first implementation, the one I've used for getting these numbers,
>> it's just preadv/pwrite from virtio_blk.c, as you correctly guessed. I
>> know it's unfair, but I wanted to take a look at the best possible
>> scenario, and then measure the cost of the other layers.
>> 
>> I'm working now on writing non-coroutine counterparts for
>> blk_co_[preadv|pwrite], so we have SIO without bypassing the block layer.
>
> Maybe try to keep the change local to file-posix.c? I think you would
> only have to modify raw_thread_pool_submit() so that it doesn't go
> through the thread pool, but just calls func directly.
>
> I don't think avoiding coroutines is possible without bypassing the block
> layer altogether because everything is really expecting to be run in
> coroutine context.

Turns out what I initially thought was a cost induced by the AIO nature
of our block layer, it's actually a bug in which polling mode works
against aio=threads, delaying the execution of the request completions.

This has been fixed by Paolo's "aio-posix: ensure poll mode is left when
aio_notify is called":

https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg01426.html

So we can throw away the idea of combining synchronous and asynchronous
requests, as it doesn't provide a significant improvement that would
justify the added complexity.

Thanks,
Sergio.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

       reply	other threads:[~2019-04-11 11:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87zhpxmkg9.fsf@redhat.com>
     [not found] ` <20190315150036.GA11173@stefanha-x1.localdomain>
     [not found]   ` <87a7hwm9t4.fsf@redhat.com>
     [not found]     ` <20190315155010.GG5368@linux.fritz.box>
2019-04-11 11:41       ` Sergio Lopez [this message]
2019-04-11 11:41         ` [Qemu-devel] Combining synchronous and asynchronous IO Sergio Lopez

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=87pnps3h1l.fsf@redhat.com \
    --to=slp@redhat.com \
    --cc=fam@euphon.net \
    --cc=jusual@mail.ru \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.