udp: preallocate ports sparse vec map 80/37680/6
authorFlorin Coras <fcoras@cisco.com>
Sat, 19 Nov 2022 02:29:23 +0000 (18:29 -0800)
committerDave Barach <openvpp@barachs.net>
Mon, 28 Nov 2022 19:31:59 +0000 (19:31 +0000)
commit797562c86066411c29116cc099864f12c98561d9
tree828516d730a39080d37a9a62ba6e782ea28af695
parent7943c90b2e341e6e064538f31746e326cd7c4e42
udp: preallocate ports sparse vec map

Not ideal. The sparse vector used to map ports to next nodes assumes
only a few ports are ever used. When udp transport is enabled this does
not hold and, to make matters worse, ports are consumed in a random
order.

This can lead to a lot of slow updates to internal data structures
which in turn can slow udp connection allocations until all ports are
eventually consumed.

Consequently, reallocate sparse vector, preallocate all ports and have
them point to UDP_NO_NODE_SET. We could consider switching the sparse
vector to a preallocated vector but that would increase memory
consumption for vpp deployments that do not rely on host stack.

For reference, populating one of the v4 or v6 sparse vectors in reverse
order takes about 9.8s on a skylake cpu.

Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Id795e1805d0d3ba54f56a152a9506a7a2a06ecbc
src/vnet/udp/udp.c