]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
nft Increase mnl_talk() receive buffer size
authorPhil Sutter <phil@nwl.cc>
Wed, 28 Aug 2019 20:10:40 +0000 (22:10 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 23 Sep 2019 11:05:50 +0000 (13:05 +0200)
This improves cache population quite a bit and therefore helps when
dealing with large rulesets. A simple hard to improve use-case is
listing the last rule in a large chain. These are the average program
run times depending on number of rules:

rule count | legacy | nft old | nft new
---------------------------------------------------------
 50,000 | .052s | .611s | .406s
100,000 | .115s | 2.12s | 1.24s
150,000 | .265s | 7.63s | 4.14s
200,000 | .411s | 21.0s | 10.6s

So while legacy iptables is still magnitudes faster, this simple change
doubles iptables-nft performance in ideal cases.

Note that using a larger buffer than 32KB doesn't further improve
performance since linux kernel won't transmit more data at once. This
limit was set (actually extended from 16KB) in kernel commit
d35c99ff77ecb ("netlink: do not enter direct reclaim from
netlink_dump()").

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
iptables/nft.c

index 77ebc4f651e15adbba11154e9f3d867a5a2812a7..8047a51f00493b80f37e4d1e41ea494e7d06c93f 100644 (file)
@@ -101,7 +101,7 @@ int mnl_talk(struct nft_handle *h, struct nlmsghdr *nlh,
             void *data)
 {
        int ret;
-       char buf[16536];
+       char buf[32768];
 
        if (mnl_socket_sendto(h->nl, nlh, nlh->nlmsg_len) < 0)
                return -1;