From: Sun YangKai <sunk67188@gmail.com>
To: sunk67188@gmail.com
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/3] btrfs: search_tree ioctl performance improvements and cleanups
Date: Sat, 26 Jul 2025 21:51:38 +0800 [thread overview]
Message-ID: <20250726135214.16000-1-sunk67188@gmail.com> (raw)
In-Reply-To: <20250612043311.22955-1-sunk67188@gmail.com>
This series optimizes the search_tree ioctl path used by tools like
compsize and cleans up related code:
Patch 1: Narrow loop variable scope
Patch 2: Early exit for out-of-range keys
Replace continue with early exit when keys exceed max_key
Provide measurable performance improvements:
Cold cache: 34.61s → 30.40s (about 12% improvement)
Hot cache: 14.19s → 10.57s (about 25% improvement)
Patch 3: Simplify key range checking
Replace key_in_sk() helper with direct comparisons
Add ASSERT for min_key validation (safe due to forward search)
Maintain equivalent functionality with cleaner implementation
These changes optimize a critical path for filesystem analysis tools while
improving code maintainability. The performance gains are particularly
noticeable when scanning large filesystems.
Thanks,
Sun YangKai
---
Changes since v1:
* Replace the WARN_ON with ASSERT, since the condition is a runtime error.
Suggested by David Sterba.
---
Sun YangKai (3):
btrfs: narrow loop variable scope in copy_to_sk()
btrfs: early exit the searching process in search_tree ioctl
btrfs: replace key_in_sk() with a simple btrfs_key compare
fs/btrfs/ioctl.c | 55 +++++++++++++++++-------------------------------
1 file changed, 19 insertions(+), 36 deletions(-)
--
2.50.0
next prev parent reply other threads:[~2025-07-26 13:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 4:31 [PATCH 0/3] btrfs: search_tree ioctl performance improvements and cleanups Sun YangKai
2025-06-12 4:31 ` [PATCH 1/3] btrfs: narrow loop variable scope in copy_to_sk() Sun YangKai
2025-06-12 4:31 ` [PATCH 2/3] btrfs: early exit the searching process in search_tree ioctl Sun YangKai
2025-06-12 4:31 ` [PATCH 3/3] btrfs: replace key_in_sk() with a simple btrfs_key compare Sun YangKai
2025-06-19 13:43 ` David Sterba
2025-06-19 14:31 ` Sun YangKai
2025-06-19 13:51 ` [PATCH 0/3] btrfs: search_tree ioctl performance improvements and cleanups David Sterba
2025-07-26 13:51 ` Sun YangKai [this message]
2025-07-26 13:51 ` [PATCH v2 1/3] btrfs: narrow loop variable scope in copy_to_sk() Sun YangKai
2025-07-26 13:51 ` [PATCH v2 2/3] btrfs: early exit the searching process in search_tree ioctl Sun YangKai
2025-07-26 13:51 ` [PATCH v2 3/3] btrfs: replace key_in_sk() with a simple btrfs_key compare Sun YangKai
2025-08-12 12:05 ` [PATCH v2 0/3] btrfs: search_tree ioctl performance improvements and cleanups Sun YangKai
2025-09-09 10:54 ` 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=20250726135214.16000-1-sunk67188@gmail.com \
--to=sunk67188@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.