Multithreading
User Plane Gateway (UPG) supports multithreading. When multithreading is enabled, Vector Packet Processing (VPP) runs one main thread plus multiple worker threads that process packets in parallel across CPU cores.
Enable multithreading
To enable multithreading, set spec.vpp.multicore to true in the UPGDeployment CR:
In multicore mode, VPP allocates one core for the main thread and uses the remaining cores available to the pod as worker cores.
Three fields control how many cores VPP uses. The following table lists them in the order VPP resolves them:
Kubernetes applies spec.resources.cpu as both the CPU request and the CPU limit. That allocation bounds spec.vpp.maxCPUCores, and a cap cannot raise the thread count above the allocation. The Thread allocation table lists how many threads each allocation yields.
spec.vpp.staticCPUCores overrides the other two fields. When you set it, VPP ignores spec.vpp.maxCPUCores and spec.vpp.multicore, and the core list alone decides the thread count. The pod then runs without a CPU request or limit, so spec.resources.cpu has no effect. Without CPU resources, the VPP container has no cgroup cpuset limit.
On a host with hyper-threading, spec.vpp.allowHtSiblings decides how much CPU each thread costs. With the default false, a VPP thread takes a whole physical core, which is two logical CPUs on a hyper-threaded host. With true, a thread takes a single sibling, so the same number of threads fits in half the physical cores.
The two settings suit different limits. Set it to true when physical cores are scarce, because the deployment then reaches a given thread count on half of them. Leave it at the default when each thread has to carry as much as the host can give, because a thread that owns a whole core carries more than one that shares it. Performance lists both sides of that trade.
Important
spec.vpp.allowHtSiblings is intended for testing only. The Fast Path Provider (FPP) VPPDeployment, FPPDeployment, and CGWDeployment schemas mark their own allowHtSiblings field the same way. The benchmark ran UPG on siblings without errors, and Performance records the throughput it measured.
Sizing
The main thread forwards traffic only while it is the only thread. As soon as one worker exists, the main thread becomes control-plane only, and all forwarding moves to the workers. One main thread plus one worker therefore still gives a single forwarding thread. That costs twice the CPU of a main-only deployment, with no throughput gain.
Provision either a main-only deployment or at least two workers, and skip the single-worker configuration in between. The Performance page records the throughput measured for each configuration.
Auto memif queue placement
When you enable multithreading, auto placement configures the receive (Rx) and transmit (Tx) queues on the following in-memory interfaces (memifs):
- Access Network interface (GRX)
- Data Network interface (SGi)
- Network Address Translation (NAT) pool interfaces
Auto placement sets the number of queues and distributes them across the worker threads, so each worker handles a share of the traffic.
Each of these interfaces connects UPG to the VPPSwitch pod of FPP. On each side, auto placement adds the main thread to Tx queue 0, because the main thread sends some packets itself. On the UPG side, these packets include:
- Address Resolution Protocol (ARP) probes
- Neighbor Discovery (ND) probes
- IP Flow Information Export (IPFIX) templates
Disable auto placement for a single interface
To override auto placement on a specific interface, set any of the following fields under that interface in spec.instances.{name}.networking.{interface}:
- numRxQueues sets the number of Rx queues.
- numTxQueues sets the number of Tx queues.
- txPlacement sets the Tx queue placement on the VPPSwitch side. VPPSwitch sends on the queues that UPG receives on, so the array has one entry for each of the numRxQueues queues. Each entry is a comma-separated list of the VPPSwitch threads that send on that queue.
- clientTxPlacement sets the Tx queue placement on the UPG side. The array has one entry for each of the numTxQueues queues. Each entry is a comma-separated list of the UPG threads that send on that queue.
If you set any of these fields on an interface, UPG skips auto placement for that interface and uses only your values.
Thread 0 is the main thread, and threads 1 and higher are the workers. Each thread that sends packets on the interface needs a Tx queue, including thread 0. In txPlacement and clientTxPlacement, add thread 0 to the list of queue 0, as auto placement does. On a side without workers, use "0" for every queue.
Caution
If no list includes thread 0, VPP discards every packet from the main thread on the interface. VPP counts these packets as no tx queue available. For example, the ARP and ND probes from the main thread do not reach the neighbors, so VPP removes the neighbor entries. VPP then drops the packets to each neighbor until VPP resolves the neighbor again.
The following example configures the SGi interface for two workers on each side:
On each side, threads 0 and 1 share queue 0, and thread 2 uses queue 1.
Disable auto placement globally
To disable auto queue placement on all dataplane interfaces, set spec.vpp.queuesFastAutoAllocation to false:
When auto placement is disabled globally, every dataplane interface uses the default single-queue configuration unless you override it with the fields listed in Disable auto placement for a single interface.
Verification
Check the running threads and per-interface queue placement with vppctl in the UPG pod.
List the VPP threads and check that they match the configuration:
bashSample output:
txtOne
vpp_mainthread plus onevpp_wk_Nper worker. Each thread is pinned to a host CPU (lcore), andCoreis its physical core ID.Check the Rx queue placement across worker threads on all interfaces:
bashSample output:
txtEach dataplane interface queue is pinned to a single worker thread.
Inspect the memif Rx/Tx queue counts on a specific dataplane interface:
bashReplace
sgiwith the interface name configured in spec.instances.{name}.networking.{interface}.interface.Sample output:
txtnum-s2m-ringsandnum-m2s-ringsshow the configured Rx and Tx queue counts on the interface.
When all checks pass, the threads and queues match the configuration.