utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
27.27k stars 1.35k forks source link

Slow network performance in Linux VMs #3490

Open vit9696 opened 2 years ago

vit9696 commented 2 years ago

Describe the issue

UTM provides very slow ip forwarding in bridged mode. The exact reasons to me are unclear.

I have Debian 11 (Linux 5.10) x86_64 installed (the version does not matter much) with 4 GB of RAM, 4 CPU cores, and a network card in bridged mode. The virtual machine runs on 192.168.1.2 host, and sits on 192.168.1.175. Gateway is 192.168.1.1. Let's say I want to analyse the traffic in my VM from 192.168.1.0/24 (e.g. my 192.168.1.2 host), for that I do the following:

My connection is ≈500/500 Mbps. I can get these speeds on both host and guest if I run speedtest there. Whenever I change the gateway to 192.168.1.175 in any machine on 192.168.1.0/24 (let's say host, but it does not matter too much), its network speed (verified by speedtest again) goes down to approximately:

I could have imagined the issue to be in the hardware/Linux guest configuration, but with VMware Fusion 12.2.1 I am able to reach around:

Configuration

I can upload a test vm, but really any Linux distro would do, it is just all about installing iptables and running two commands. The results do not change if I allocate 8 cores and 8 GB or RAM to the VM, so it is not obviously performance bound. Disabling the hypervisor makes it cap around 120 Mbps.

At this step I have three questions:

osy commented 2 years ago

Related to #3449 it’s possibly due to using immature patches in QEMU.

vit9696 commented 2 years ago

Possible, but I am not sure it is the only thing here. I did a few more tests, and they brought nothing but confusion.

I guess I can live with Ubuntu 21.10 and virtio-net-pci. As for this issue:

UPDATE: It seems that the performance boosts with Ubuntu 21.10 are rather random. Most certainly there is a bug in QEMU drivers, which results in sporadic slowdowns as I cannot reproduce decent speed now despite keeping same other parameters, but what I can reproduce is that the speeds are different over the reboots and they can vary from 130 to 250 Mbps.

lonestriker commented 2 years ago

I'm getting similarly poor network performance with UTM on any upload file transfers. For example, if I scp or rsync from my UTM M1 macOS OS to another Linux box, I only get 50-100 KB/s transfer speeds. If I instead rsync or scp from Linux to UTM, the speeds are 10+ MB/s. Configuring the UTM M1 Mac for either shared (NAT) or bridged networking makes no difference in speed. Doing a non-UTM scp or rsync either upload or download works very quickly, so there's no issue with the native system itself.

I also see the same poor upload network performance running the UTM ARM Debian image. Same slow scp or rsync upload and very fast downloads.

This slow macOS upload is the only issue I can find with the virtualized Mac. It's awesome otherwise in terms of performance.

lonestriker commented 2 years ago

A bit more testing on the poor network performance using the latest UTM 3.1.2 (49) BETA:

There's no option though with the Mac M1 virtualization to change he network emulation unfortunately. I get very slow upload speeds using rsync still under the Mac VM (100 KB/s). But, if I mount an NFS network share (using v4 protocol) on the Mac VM, I can copy files very quickly there. So, something very odd about specific protocols like rsync or scp are slow, but NFS is fast.