]> git.ipfire.org Git - thirdparty/nftables.git/commit
cache: populate chains on demand from error path
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 15 Aug 2024 10:34:11 +0000 (12:34 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 19 Aug 2024 15:24:31 +0000 (17:24 +0200)
commitbabc6ee8773cfeed78167f78827b35e3141e04c6
tree9470ec2b5cc0d0a7b11f37408f579bf3fbb307fe
parent161beaeacd2e5218d66febc3db825bf6a27119c5
cache: populate chains on demand from error path

Updates on verdict maps that require many non-base chains are slowed
down due to fetching existing non-base chains into the cache.

Chains are only required for error reporting hints if kernel reports
ENOENT. Populate the cache from this error path only.

Similar approach already exists from rule ENOENT error path since:

  deb7c5927fad ("cmd: add misspelling suggestions for rule commands")

however, NFT_CACHE_CHAIN was toggled inconditionally for rule
commands, rendering this on-demand cache population useless.

before this patch, running Neels' nft_slew benchmark (peak values):

  created idx 4992 in 52587950 ns   (128 in 7122 ms)
  ...
  deleted idx  128 in 43542500 ns   (127 in 6187 ms)

after this patch:

  created idx 4992 in 11361299 ns   (128 in 1612 ms)
  ...
  deleted idx 1664 in  5239633 ns   (128 in 733 ms)

Tested-by: Eric Garver <eric@garver.life>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/cache.h
src/cache.c
src/cmd.c