From: Florian Westphal <fw@strlen.de>
To: Kerin Millar <kfm@plushkava.net>
Cc: netfilter@vger.kernel.org
Subject: Re: nftables rule optimization - evaluating efficiency
Date: Wed, 10 Jul 2024 23:39:01 +0200 [thread overview]
Message-ID: <20240710213901.GB550@breakpoint.cc> (raw)
In-Reply-To: <1c12afa3-40fd-48df-9076-92277570ef3b@app.fastmail.com>
Kerin Millar <kfm@plushkava.net> wrote:
> On Wed, 10 Jul 2024, at 7:34 PM, William N. wrote:
> > On Tue, 2 Jul 2024 19:03:18 -0000 William N. wrote:
> >
> >> [...]
> >> Also, it is not clear what is the actual "load" of different
> >> instructions in terms of CPU cycles and memory, i.e. one instruction
> >> may look as "one" but may actually cost more than another 2, right?
>
> Indeed. It cannot be presumed that all instructions are equal in expense.
Yes, but then again nft will try to make reasonable choices.
tcp dport { 22, 80 } will not allocate a huge hash table for two values.
Is it faster than
tcp dport 22
tcp dport 80
?
No idea. And given the volume of bugs I don't really care too much.
> >> What is the proper way to evaluate and optimize rule efficiency?
> >
> > Are those difficult or somehow inappropriate questions?
> > Or is there a better place to ask?
>
> You are enquiring as to how to assess the relative efficiency of the bytecode instructions through the direct understanding of how they are processed by the nftables VM. Said VM is unique and - as far as I know - wholly undocumented. As regards difficulty, the intersection of people who follow the list and possess the necessary expertise can probably be conveyed quite comfortably by a single digit. It is a pity; I would also have been interested to see an informed reply but the absence of one wasn't altogether surprising to me.
The additional issue that its hard to give a useful answer.
Use 'perf record -a ... and pktgen' is likely a rather useless reply.
And might even incorrect depending on what one wants to measure.
In general, its best to compact the ruleset as much as possible
and use sets/maps/vmaps wherever possible.
next prev parent reply other threads:[~2024-07-10 21:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 19:03 nftables rule optimization - evaluating efficiency William N.
2024-07-03 9:37 ` Reindl Harald
2024-07-03 10:44 ` William N.
2024-07-10 18:34 ` William N.
2024-07-10 21:27 ` Kerin Millar
2024-07-10 21:39 ` Florian Westphal [this message]
2024-07-11 19:15 ` William N.
2024-07-11 19:14 ` William N.
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=20240710213901.GB550@breakpoint.cc \
--to=fw@strlen.de \
--cc=kfm@plushkava.net \
--cc=netfilter@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;
as well as URLs for NNTP newsgroup(s).