From: Chris Arges <carges@cloudflare.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de
Subject: Re: [PATCH nf] netfilter: nft_set_rbtree: revisit array resize logic
Date: Thu, 12 Mar 2026 15:35:04 -0500 [thread overview]
Message-ID: <abMjeP3jMDa3HE81@20HS2G4> (raw)
In-Reply-To: <20260312011423.3492328-1-pablo@netfilter.org>
On 2026-03-12 02:14:23, Pablo Neira Ayuso wrote:
> Start by 8192 slots in the array and expand it by pow of 2 to simplify
> growth and shrink logic.
>
> Use set->ndeact to subtract deactivated elements when calculating the
> number of the slots in the array.
>
> Add shrink logic to deal with flush+add set, otherwise the array size
> array gets increased artifically.
>
> Reported-by: Chris Arges <carges@cloudflare.com>
> Fixes: 7e43e0a1141d ("netfilter: nft_set_rbtree: translate rbtree to array for binary search")
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> Chris, I'm posting this patch, but I am not sure it fits into the
> scenario you described.
>
Pablo,
Thank you, I was able to test this and here are my results:
* v6.18.13 (before nft_set_rbtree patches)
Slab unreclaimable memory increases to 1.4G then levels off.
* v6.18.17 (no patches)
Slab unreclaimable memory increases to 4.9G then levels off.
* v6.18.17 + this patch + nft_set_rbtree: allocate same array size on updates
Slab unreclaimable memory increases to 3.1G then levels off.
* v6.18.17 + this patch + nft_set_rbtree: allocate same array size on updates +
NFT_ARRAY_INITIAL_SIZE 1024
Slab unreclaimable memory increases to 1.6G then levels off.
So looks like this patch is a huge improvement! One modification I was able to
test was setting NFT_ARRAY_INITIAL_SIZE to 1024. With that change I was getting
a memory profile similar to before this patch:
- 7e43e0a1141d netfilter: nft_set_rbtree: translate rbtree to array for binary search
--chris
prev parent reply other threads:[~2026-03-12 20:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 1:14 [PATCH nf] netfilter: nft_set_rbtree: revisit array resize logic Pablo Neira Ayuso
2026-03-12 20:35 ` Chris Arges [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=abMjeP3jMDa3HE81@20HS2G4 \
--to=carges@cloudflare.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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