From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
To: Peng Zhang <zhangpeng.00@bytedance.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, maple-tree@lists.infradead.org
Subject: Re: [PATCH] maple_tree: Avoid checking other gaps after getting the largest gap
Date: Mon, 18 Dec 2023 15:20:14 -0500 [thread overview]
Message-ID: <20231218202014.mpotsekdkszasn4t@revolver> (raw)
In-Reply-To: <20231215074632.82045-1-zhangpeng.00@bytedance.com>
* Peng Zhang <zhangpeng.00@bytedance.com> [231215 02:46]:
> The last range stored in maple tree is typically quite large. By
> checking if it exceeds the sum of the remaining ranges in that node, it
> is possible to avoid checking all other gaps.
>
> Running the maple tree test suite in user mode almost always results in
> a near 100% hit rate for this optimization.
This should only be triggered for right-most nodes and root though,
correct (mas->max == ULONG_MAX from just before this)?
I wonder if it's worth special case checking the first gap if the node
min is 0 as well. Might be worth looking at, but this patch is
certainly worth doing.
>
> Signed-off-by: Peng Zhang <zhangpeng.00@bytedance.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
> lib/maple_tree.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index c9a970ea20dd..6f241bb38799 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -1518,6 +1518,9 @@ static unsigned long mas_leaf_max_gap(struct ma_state *mas)
> gap = ULONG_MAX - pivots[max_piv];
> if (gap > max_gap)
> max_gap = gap;
> +
> + if (max_gap > pivots[max_piv] - mas->min)
> + return max_gap;
> }
>
> for (; i <= max_piv; i++) {
> --
> 2.20.1
>
next prev parent reply other threads:[~2023-12-18 20:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 7:46 Peng Zhang
2023-12-18 20:20 ` Liam R. Howlett [this message]
2023-12-18 20:28 ` Liam R. Howlett
2023-12-19 2:34 ` Peng Zhang
2023-12-19 9:14 ` Liam R. Howlett
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=20231218202014.mpotsekdkszasn4t@revolver \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=zhangpeng.00@bytedance.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