Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Sun YangKai <sunk67188@gmail.com>
To: Boris Burkov <boris@bur.io>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: fix node balancing condition in balance_level()
Date: Wed, 06 Aug 2025 14:07:06 +0800	[thread overview]
Message-ID: <2384779.ElGaqSPkdT@saltykitkat> (raw)
In-Reply-To: <20250805184615.GD4088788@zen.localdomain>

> This is interesting, good catch.
> 
> However, we don't really have any evidence one way or the other which is
> better. For better or worse, this logic has been around since ~2007, so
> to change it I think requires more justification than the reasoning on a
> 
> faulty patch from 2009. Do you have any evidence for your #3:
>   > Improve btree performance by more frequent node compaction
> 
> I would advise that you run:
> - fsperf for generic benchmarking.
> - a targeted workload that would get compacted more now that you removed
>   the surprising check.
> 
> Thanks,
> Boris

Hi Boris.

The performance might get better because we will have less nodes and even 
lower trees, if we compact nodes when they are 50% full instead of 25% full. 
But I've not benched yet and there's some problem in it.

I come up with a drawback. This patch will make it more frequently to 
split a nearly full node into two and merge them back later again and again if 
item count changes slightly and its neighbors cannot help balance some items, 
which happens when:

1. left node is full or null and we are always operating the left-half part of 
the mid node
2. right node is null

The leaf merge related code choose (cap/3) instead of (cap/2) to prevent 
similar cases. I have no idea how often this could be triggered in real world 
workload. But if it really hurts, we should try some other method to merge/
split the nodes to get better performance.

Anyway, thank you for your advice. And I'm working on fsperf.

Thanks,
Sun YangKai






  reply	other threads:[~2025-08-06  6:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05  3:57 [PATCH] btrfs: fix node balancing condition in balance_level() Sun YangKai
2025-08-05 18:46 ` Boris Burkov
2025-08-06  6:07   ` Sun YangKai [this message]
2025-08-07 15:06   ` Sun YangKai

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=2384779.ElGaqSPkdT@saltykitkat \
    --to=sunk67188@gmail.com \
    --cc=boris@bur.io \
    --cc=linux-btrfs@vger.kernel.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