linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Ole Tange <tange@gnu.org>, linux-btrfs@vger.kernel.org
Subject: Re: Btrfs compression ratio > 34:1 possible?
Date: Tue, 12 Jan 2021 08:40:13 +0800	[thread overview]
Message-ID: <7b4cded9-01fa-4dff-8aaf-fcedc3b27562@gmx.com> (raw)
In-Reply-To: <CA+4vN7xn4h8HjnkE5wpKw6VMrf9NCLCyheme2PspgheG3DmmvA@mail.gmail.com>



On 2021/1/12 上午7:32, Ole Tange wrote:
> I am trying to use Btrfs' compression on some highly compressible data.
>
> I try to make zstd give better performance than 34:1.
>
> This:
>
>     $ truncate -s 1T /tmp/btrfs
>     $ mkfs.btrfs /tmp/btrfs
>     $ mount -o compress=zstd:9  /tmp/btrfs /mnt/btrfs
>     $ head -c 10G /dev/zero > /mnt/btrfs/zero
>     $ du /tmp/btrfs
>     313672k
>
> shows a compression ratio of 10737418240/312724/1024 = 33.5:1
>
> But if I run:
>
>     $ head -c 10G /dev/zero | zstd | wc -c
>     336655
>
> I get a compression ratio of 10737418240/336655 = 31894:1
>
> That is around 1000 times better.
>
> I understand there is some overhead in Btrfs, so it is expected that
> it is not possible to reach the full ratio. But it seems there is
> little to no difference in using 'compress=zstd:9' and
> 'compress=zstd:3' on highly compressible data.
>
> My guess is, that data is chopped up in small blocks (1k?) that are
> each compressed. If so: Is it possible to make these blocks bigger? I
> think that would make sense in general when using higher compression
> values.

For compressed data, btrfs has a size limit for data extent, which is
128K. The number is to balance between compression ratio and extra
decompression for CoWed extents.

On the other hand, btrfs (any fs) has its minimal block size, and it's
4K for x86_64.

So the upper limit you can get is 128K / 4K = 32.

Thanks,
Qu

>
>
> /Ole
>

      reply	other threads:[~2021-01-12  0:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 23:32 Btrfs compression ratio > 34:1 possible? Ole Tange
2021-01-12  0:40 ` Qu Wenruo [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=7b4cded9-01fa-4dff-8aaf-fcedc3b27562@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=tange@gnu.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).