Re: Bhyve process consumes way too much CPU

From: Miroslav Lachman <000.fbsd_at_quip.cz>
Date: Sun, 19 Mar 2023 18:12:11 UTC
On 18/03/2023 14:59, Julie Koubová wrote:
> Hey everyone,
> 
> I'm running Linux (Home Assistant OS) in Bhyve on FreeBSD 13.1. I use 
> PCI passthrough to allow the VM to access a USB card with a couple of 
> radio dongles. The host machine is an Intel Core i3 13100 with 64 GB of 
> RAM. The CPU has 4 physical cores (8 hyper-threaded). The virtual 
> machine is assigned four cores.
> 
> The host load averages are 0.39 0.39 0.40 right now, which seems way too 
> much. The same workload was previously handled by a Raspberry Pi 4, and 
> the CPU usage there was under 10% when not doing anything special. 
> Inside the guest OS, the CPU usage is reported around 5%, which seems 
> reasonable.
> 
> What's wrong? How can I start debugging this issue? I use ZFS on the 
> host, vm-bhyve to manage the virtual machines, and I don't have a swap 
> partition.

I had similar problem few years ago. Never solved. Exhibited on bhyve 
and VirtualBox too. The problem was "the more vCPU for VM, the slower VM".
Can you try to set just 1 vCPU to your VM? In my case, VM with 1 vCPU 
was fast, almost no overhead, 2 v CPUs slightly slower but 4 or more was 
slow as hell.
I would also recommend not to overprovision real CPU core count to vCPU 
and not use multi/hyper threading cores as real cores. With your CPU, 
use only 4 cores to assign to all your VMs (4 VMs with 1 vCPU each, or 2 
VMs with 2 vCPU each, 1 VM with 4 vCPU)

Miroslav Lachman