From: David Sterba <dsterba@suse.cz>
To: Daniel Vacek <neelx@suse.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>, Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] btrfs: index buffer_tree using node size
Date: Sat, 5 Jul 2025 14:26:05 +0200 [thread overview]
Message-ID: <20250705122605.GA4453@twin.jikos.cz> (raw)
In-Reply-To: <20250704160704.3353446-1-neelx@suse.com>
On Fri, Jul 04, 2025 at 06:07:02PM +0200, Daniel Vacek wrote:
> So far we are deriving the buffer tree index using the sector size. But each
> extent buffer covers multiple sectors. This makes the buffer tree rather sparse.
>
> For example the typical and quite common configuration uses sector size of 4KiB
> and node size of 16KiB. In this case it means the buffer tree is using up to
> the maximum of 25% of it's slots. Or in other words at least 75% of the tree
> slots are wasted as never used.
>
> We can score significant memory savings on the required tree nodes by indexing
> the tree using the node size instead. As a result far less slots are wasted
> and the tree can now use up to all 100% of it's slots this way.
>
> Note: This works even with unaligned tree blocks as we can still get unique
> index by doing eb->start >> nodesize_shift.
>
> Getting some stats from running fio write test, there is a bit of variance.
> The values presented in the table below are medians from 5 test runs.
> The numbers are (# of allocated ebs in the tree / # of leaf tree nodes /
> / highest index in the tree (radix tree width)):
>
> ebs / leaves / Index | bare for-next | with fix
> ---------------------+--------------------+-------------------
> post mount | 16 / 11 / 10e5c | 16 / 10 / 4240
> post test | 5810 / 891 / 11cfc | 4420 / 252 / 473a
> post rm | 574 / 300 / 10ef0 | 540 / 163 / 46e9
>
> In this case (10 gig FS) the height of the tree is still 3 levels but the
> 4x width reduction is clearly visible as expected. But since the tree is
> more dense we can see the 54-72% reduction of leaf nodes. That's very
> close to ideal with this test. It means the tree is getting really dense
> with this kind of workload.
>
> Also, the fio results show no performance change.
>
> Signed-off-by: Daniel Vacek <neelx@suse.com>
> Reviewed-by: Qu Wenruo <wqu@suse.com>
> ---
> V3 changes: Mentioned stats diff in the commit message and rebased.
Added to for-next, thanks. Please also format the changelog lines to 72
or 74 chars.
prev parent reply other threads:[~2025-07-05 12:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 16:07 Daniel Vacek
2025-07-05 12:26 ` David Sterba [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=20250705122605.GA4453@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neelx@suse.com \
--cc=wqu@suse.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
all inboxes | Powered by JetHome®