qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: PANKAJ RAWAT <pankajr141@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Cluster_size parameter issue on qcow2 image format
Date: Thu, 23 Feb 2012 08:32:04 +0000	[thread overview]
Message-ID: <20120223083204.GA10698@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <CABZruFAg81ayd3P6RWKnbhLMW9jmN00hcp=LRsbMHZ3NgupA2A@mail.gmail.com>

On Thu, Feb 23, 2012 at 11:01:46AM +0530, PANKAJ RAWAT wrote:
> I theory regarding  cluster size it is written that as the size of cluster
> increase performance should increase.
> 
> But something surprising happen The performance is degrading as the size of
> cluster increased from 64K to 1M  ( during expansion of qcow2 image)

It's not true that performance should increase by raising the cluster
size, otherwise the default would be infinity.  It's an algorithms/data
structure trade-off.

Most importantly is the relative latency between a small guest I/O
request (e.g. 4 KB) and the cluster size (e.g. 64 KB).  If the cluster
size latency is orders of magnitude larger than a small guest I/O
request, then be prepared to see extreme effects described below:

 * Bigger clusters decrease the frequency of metadata operations and
   increase metadata cache hit rates.  Bigger clusters means less
   metadata so qcow2 performs fewer metadata operations overall.

   Performance boost.

 * Bigger clusters increase the cost of allocating a new cluster.  For
   example, a 8 KB write to a new cluster will incur a 1 MB write to the
   image file (the untouched regions are filled with zeros).  This can
   be optimized in some cases but not everywhere (e.g. reallocating a
   data cluster versus extending the image file size and relying on the
   file system to provide zeroed space).  This is especially expensive
   when a backing file is in use because up to 1 MB of the backing file
   needs to be read to populate the newly allocated cluster!

   Performance loss.

 * Bigger clusters can reduce fragmentation of data on the physical
   disk.  The file system sees fewer, bigger allocating writes and is
   therefore able to allocate more contiguous data - less fragmentation.

   Performance boost.

 * Bigger clusters reduce the compactness of sparse files. you use more
   image file space on the host file system when the cluster size is
   large.

   Space efficiency loss.

Here's a scenario where a 1 MB cluster size is great compared to a large
cluster size:

You have a fully allocated qcow2 image, you will never need to do any
allocating writes.

Here's a scenario where a 1 MB cluster size is terrible compared to a
small cluster size:

You have an empty qcow2 file and perform 4 KB writes to the first sector
of each 1 MB chunk, and there is a backing file.

So it depends on the application.

Stefan

  reply	other threads:[~2012-02-23  9:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23  5:31 [Qemu-devel] Cluster_size parameter issue on qcow2 image format PANKAJ RAWAT
2012-02-23  8:32 ` Stefan Hajnoczi [this message]
2012-02-23 10:02   ` PANKAJ RAWAT
2012-02-23 10:16     ` Stefan Hajnoczi
2012-02-23 11:08       ` PANKAJ RAWAT

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=20120223083204.GA10698@stefanha-thinkpad.localdomain \
    --to=stefanha@gmail.com \
    --cc=pankajr141@gmail.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).