I am running dhrystone benchmarking tool to see the performance of qemu-system-riscv64 which is running ubuntu 22.04 pre-installed image. Host machine has 2 cores with 1 thread each. I ran tests on qemu-system-riscv64 in combination of 1, 2 and 4 cores (can be specified with smp
flag). I observed that when I go from 1 core to two cores for qemu-system-riscv64, the dhrystones increase but when I go from 2 cores to 4 cores, the number of dhrystones become lower than that of two cores. What can be the reason of this behavior. I am using following command to boot ubuntu 22.04:
qemu-system-riscv64 \
-machine virt -nographic -m 2048 -smp 4 \
-kernel $UBOOTPATH/u-boot.bin \
-device virtio-net-device,netdev=eth0 -netdev user,id=eth0,hostfwd=::<host_port>-:<VM_port> \
-drive file=ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img,format=raw,if=virtio
I also tried running make
with -j
flag, the same behavior occurs when I use -j4
and -j2
as is described above.
Qemu target riscv64-softmmu supports MTTCG, so every emulated guest core runs in a separate host thread, thus guest performance is saturated by the total host processing power. I.e. with a guest capable of using all available guest cores on an otherwise idle host system adding a new guest core will increase overall guest performance as long as the total number of guest cores does not exceed the number of host cores. After that the host CPU load will approach 100% and adding new guest cores will only increase concurrence for the host CPU time.