4. Performance Optimization

4.1. Reduce Context Switches

Use the isolcpus Linux kernel parameter to isolate them from Linux scheduler to reduce context switches. It prevents workloads of other processes than DPDK running on reserved cores with isolcpus parameter.

For Ubuntu 16.04, define isolcpus in /etc/default/grub.


The value of this isolcpus depends on your environment and usage. This example reserves six cores(0,1,2,3,5,7).

4.2. Optimizing QEMU Performance

QEMU process runs threads for vcpu emulation. It is effective strategy for pinning vcpu threads to decicated cores.

To find vcpu threads, you use ps command to find PID of QEMU process and pstree command for threads launched from QEMU process.

$ ps ea
192606 pts/11   Sl+    4:42 ./x86_64-softmmu/qemu-system-x86_64 -cpu host ...

Run pstree with -p and this PID to find all threads launched from QEMU.

$ pstree -p 192606

Update affinity by using taskset command to pin vcpu threads. The vcpu threads is listed from the second entry and later. In this example, assign PID 192623 to core 4, PID 192624 to core 5 and so on.

$ sudo taskset -pc 4 192623
pid 192623's current affinity list: 0-31
pid 192623's new affinity list: 4
$ sudo taskset -pc 5 192624
pid 192624's current affinity list: 0-31
pid 192624's new affinity list: 5
$ sudo taskset -pc 6 192625
pid 192625's current affinity list: 0-31
pid 192625's new affinity list: 6
$ sudo taskset -pc 7 192626
pid 192626's current affinity list: 0-31
pid 192626's new affinity list: 7