qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC] Use O_DSYNC by default and update documentation to explain IO integrity in QEMU
Date: Fri, 10 Oct 2008 11:27:08 +0200	[thread overview]
Message-ID: <48EF1FEC.20403@redhat.com> (raw)
In-Reply-To: <48EE390A.6070601@codemonkey.ws>

Anthony Liguori wrote:
>  
> +By default, QEMU accesses all disk data through the host's page cache.
> +This allows the host to perform read-ahead and to avoid duplicating IO
>   

The guest does read-ahead as well, so this is not a good thing.  
Further, if using qcow2, host read ahead will read random data, and if 
using raw devices, host read ahead is equivalent to physical read ahead, 
whereas most OSes prefer logical (file based) read ahead.

> +requests unnecessarily increasing disk performance.  You may notice that
> +certain benchmarks in the guest perform better than they do in the host
> +(for read) because of this.  This is primarily because the benchmark is
> +unaware of the extra level of caching that is occurring when running in
> +a virtual environment.
>   

This is because the the guest is effectively running with a much larger 
cache.  If you'd given the guest this memory, it would perform even better.

IMO the only case where having the cache in the host is preferable is 
when the guest cannot utilize the memory effectively, such as when the 
guest reboots, or with older versions of Windows x86.

> +
> +The cache=off option can be used to disable the use of the host's page
> +cache.  Disabling the use of the host's page cache will likely reduce
> +performance since the host is unable to perform read-ahead and unable
> +to avoid duplicating IO requests.  At this time, QEMU will copy data
> +internally so the cost of copying data into the host's page cache is
> +unlikely to be statistically significant.
>   

It's a mistake to optimize for the current state of affairs which we are 
planning to change soon.

> +In the future, QEMU will be able to avoid copying data internally and
> +under certain workloads, disabling the use of the host's page cache may
> +increase performance provided that the guest is actively working to avoid
> +bringing data into the CPU's cache.  This can only be achieved when using
> +things like sendfile() in the guest or other forms of direct-io.

Guest read ahead, write back, and pageout are also examples of transfers 
that are very likely to benefit from not touching the cache.  Other 
examples are the guest reading a metadata block and only accessing one 
inode.


-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

      reply	other threads:[~2008-10-10  9:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09 17:02 [Qemu-devel] [RFC] Use O_DSYNC by default and update documentation to explain IO integrity in QEMU Anthony Liguori
2008-10-10  9:27 ` Avi Kivity [this message]

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=48EF1FEC.20403@redhat.com \
    --to=avi@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).