From: Eric Blake <eblake@redhat.com>
To: Denis Plotnikov <dplotnikov@virtuozzo.com>,
kwolf@redhat.com, mreitz@redhat.com, armbru@redhat.com
Cc: vsementsov@virtuozzo.com, den@virtuozzo.com,
qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v1 3/3] qcow2: add zstd cluster compression
Date: Wed, 3 Jul 2019 09:36:58 -0500 [thread overview]
Message-ID: <e61d7afc-09ce-d52d-3987-df1d5ba6977f@redhat.com> (raw)
In-Reply-To: <20190703110044.25610-4-dplotnikov@virtuozzo.com>
[-- Attachment #1.1: Type: text/plain, Size: 2659 bytes --]
On 7/3/19 6:00 AM, Denis Plotnikov wrote:
> zstd significantly reduces cluster compression time.
> It provides better compression performance maintaining
> the same level of compression ratio in comparison with
> zlib, which, by the moment, has been the only compression
> method available.
>
> ---
> block/qcow2.c | 96 ++++++++++++++++++++++++++++++++++++++++++++
> configure | 32 +++++++++++++++
> qapi/block-core.json | 3 +-
> 3 files changed, 130 insertions(+), 1 deletion(-)
Where is the change to docs/interop/qcow2.txt to describe this new
compression format?
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 37a563a671..caa04b0beb 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -27,6 +27,11 @@
> #define ZLIB_CONST
> #include <zlib.h>
>
> +static ssize_t qcow2_zstd_compress(void *dest, size_t dest_size,
> + const void *src, size_t src_size)
> +{
> + ssize_t ret;
> + uint32_t *c_size = dest;
> + /* steal some bytes to store compressed chunk size */
> + char *d_buf = ((char *) dest) + sizeof(*c_size);
> +
Do you always want exactly 4 bytes for the compressed size? Or is it
worth some sort of variable-length encoding, since we're already dealing
with non-cacheline-aligned data? You can represent all sizes up to 4M
using a maximum of 3 bytes (set the high bit if the integer continues,
then sizes 0-127 take 1 byte [7 bits], 128-32767 take 2 bytes [15 bits],
and 32768-4194303 take 3 bytes [22 bits]).
> + if (dest_size < sizeof(*c_size)) {
> + return -ENOMEM;
> + }
> +
> + dest_size -= sizeof(*c_size);
> +
> + ret = ZSTD_compress(d_buf, dest_size, src, src_size, 5);
The fact that you are storing the size separate from the data passed to
zstd MUST be documented in the qcow2 spec, for the next person to
produce/consume the same data.
> +++ b/qapi/block-core.json
> @@ -4215,11 +4215,12 @@
> # Compression type used in qcow2 image file
> #
> # @zlib: zlib compression, see <http://zlib.net/>
> +# @zstd: zstd compression, see <http://github.com/facebook/zstd>
> #
> # Since: 4.1
> ##
> { 'enum': 'Qcow2CompressionType',
> - 'data': [ 'zlib' ] }
> + 'data': [ 'zlib', 'zstd' ] }
Since you patched configure so that linking against zstd is optional,
this should use { 'name':'zstd', 'if':'CONDITIONAL' } so that during
introspection, the enum only advertises zstd on a build that linked
against the library.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-07-03 14:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 11:00 [Qemu-devel] [PATCH v1 0/3] add zstd cluster compression Denis Plotnikov
2019-07-03 11:00 ` [Qemu-devel] [PATCH v1 1/3] qcow2: introduce compression type feature Denis Plotnikov
2019-07-03 14:14 ` Eric Blake
2019-07-03 15:01 ` Denis Plotnikov
2019-07-03 15:13 ` Eric Blake
2019-07-03 15:37 ` Denis Plotnikov
2019-07-03 15:46 ` Kevin Wolf
2019-07-03 15:54 ` Denis Plotnikov
2019-07-09 11:27 ` Markus Armbruster
2019-07-03 11:00 ` [Qemu-devel] [PATCH v1 2/3] qcow2: rework the cluster compression routine Denis Plotnikov
2019-07-03 11:00 ` [Qemu-devel] [PATCH v1 3/3] qcow2: add zstd cluster compression Denis Plotnikov
2019-07-03 14:36 ` Eric Blake [this message]
2019-07-03 15:06 ` Denis Plotnikov
2019-07-03 16:07 ` Kevin Wolf
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=e61d7afc-09ce-d52d-3987-df1d5ba6977f@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=den@virtuozzo.com \
--cc=dplotnikov@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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).