From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft 2/2,v2] intervals: Do not sort cached set elements over and over again
Date: Thu, 23 Jun 2022 18:17:16 +0200 [thread overview]
Message-ID: <YrSSDGNNSbrHCKdf@salvia> (raw)
In-Reply-To: <YrSPQJy7+IjLeQvA@orbyte.nwl.cc>
On Thu, Jun 23, 2022 at 06:05:20PM +0200, Phil Sutter wrote:
> On Thu, Jun 16, 2022 at 11:04:46AM +0200, Pablo Neira Ayuso wrote:
> > From: Phil Sutter <phil@nwl.cc>
> >
> > When adding element(s) to a non-empty set, code merged the two lists and
> > sorted the result. With many individual 'add element' commands this
> > causes substantial overhead. Make use of the fact that
> > existing_set->init is sorted already, sort only the list of new elements
> > and use list_splice_sorted() to merge the two sorted lists.
> >
> > Add set_sort_splice() and use it for set element overlap detection and
> > automerge.
> >
> > A test case adding ~25k elements in individual commands completes in
> > about 1/4th of the time with this patch applied.
> >
> > Joint work with Pablo.
> >
> > Fixes: 3da9643fb9ff9 ("intervals: add support to automerge with kernel elements")
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
>
> Thanks for picking it up, I missed the automerge code being very
> similar.
>
> I worked on a patch to move the whole set adjustment to a separate step
> after evaluating commands, but it's a bit larger effort as it requires
> to combine overlap detection, auto merge and element deletion. With
> simple appending new elements in eval phase and reacting upon
> EXPR_F_KERNEL and EXPR_F_REMOVE flags, I guess it's possible to update
> the whole set in one go.
You mean, appending if they come in order as in your test ruleset? Not
sure what you are suggesting.
next prev parent reply other threads:[~2022-06-23 16:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 9:04 [PATCH nft 1/2] intervals: do not empty cache for maps Pablo Neira Ayuso
2022-06-16 9:04 ` [PATCH nft 2/2,v2] intervals: Do not sort cached set elements over and over again Pablo Neira Ayuso
2022-06-23 16:05 ` Phil Sutter
2022-06-23 16:17 ` Pablo Neira Ayuso [this message]
2022-06-23 16:25 ` Phil Sutter
2022-06-23 17:19 ` Pablo Neira Ayuso
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=YrSSDGNNSbrHCKdf@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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).