fqdn/dnsproxy: Rewrite dnsproxy benchmark
fqdn/dnsproxy: Rewrite dnsproxy benchmark

This rewrites the Benchmark_perEPAllow_setPortRulesForID benchmark to
test a "real world" scenario in terms of allocations, cpu usage and heap
memory. Looong regexes take a lot of space, and the previous version of
this benchmark wasn't too representative.

In general this test will now simulate an agent that has 60 running pods
at any given time, and they keep recycling until we have created
endpoint number 10000 (nEPs). They all have distinct rules, with some
exceptions. Every everyNIsEqual EP has the same dns rules, and every
everyNHasWildcard has a wildcard rule.

This is very useful since we don't need to rely on some CNP dump, and it
behaves like a real world agent with a "limited" number of pods running
at any given time. It would also help benchmark new changes, since the
pprof dump now only contain the relevant data, and not ~mostly yaml+json
parsing like the Benchmark_perEPAllow_setPortRulesForID_large. Also,
previously it looked like this benchmark had two distinct selectors, but
since they were null, in the end it only had one.

The new "B(HeapInUse)/op" value is a rough calculation of how much the
heap size grows from the start of the benchmark to the end. This is a
very good proxy for how much memory the dnsproxy will consume during
runtime.

$ go test -v -bench='^Benchmark_perEPAllow_setPortRulesForID$' -run="^$" -benchtime 1x -memprofile memprofile.prof ./pkg/fqdn/dnsproxy

cache size of 1024:
Benchmark_perEPAllow_setPortRulesForID-7               1        91863112900 ns/op       1786241024 B(HeapInUse)/op      78642436208 B/op        167454992 allocs/op

cache size of 128:
Benchmark_perEPAllow_setPortRulesForID-7               1        88338408700 ns/op        224722944 B(HeapInUse)/op      78642493144 B/op        167456155 allocs/op

cache size of 1:
Benchmark_perEPAllow_setPortRulesForID-7               1        79318500100 ns/op        105177088 B(HeapInUse)/op      86872021272 B/op        180312236 allocs/op

cache size of 0 (disabled):
Benchmark_perEPAllow_setPortRulesForID-7               1        144261660700 ns/op       209502208 B(HeapInUse)/op      169280546296 B/op       309321759 allocs/op

Comparing the old default of a 1024 cache to 128;
name                             old time/op          new time/op          delta
_perEPAllow_setPortRulesForID-7           83.7s ±17%          103.3s ±18%  +23.44%  (p=0.032 n=5+5)

name                             old B(HeapInUse)/op  new B(HeapInUse)/op  delta
_perEPAllow_setPortRulesForID-7           1.79G ± 0%           0.22G ± 0%  -87.40%  (p=0.008 n=5+5)

name                             old alloc/op         new alloc/op         delta
_perEPAllow_setPortRulesForID-7          78.6GB ± 0%          78.6GB ± 0%     ~     (p=0.310 n=5+5)

name                             old allocs/op        new allocs/op        delta
_perEPAllow_setPortRulesForID-7            167M ± 0%            167M ± 0%     ~     (p=0.421 n=5+5)

Signed-off-by: Odin Ugedal <785541f0e54bdd28cf396d95bb334a566c03f369@palantir.com>

cilium/cilium,cilium/cilium,cilium/cilium,cilium/cilium,cilium/cilium