USB 3.2 device degraded performance inside the VM

Discussions related to using VirtualBox on Linux hosts.
Post Reply
mssm
Posts: 5
Joined: 17. Aug 2022, 12:56

USB 3.2 device degraded performance inside the VM

Post by mssm »

Hi,

I have an USB 3.2 Gen2x2 NVMe drive. My VM is using the plain USB device. It's a Linux host and guest. The host performs about 500MiB/s on that device because the host hardware doesn't seem to support latest 3.2 Gen2x2 which could theoretically perform about 2000MiB/s.
The VirtualBox guest Linux only operates at 130MiB/s (hdparm inside the VM). It's VirtualBox 6.1.32 that should not have the USB3 bug.

In the VM Settings->USB-> I have [x]Enable USB Controller, [x] USB 3.0 (xHCI) and filtered the specific device. lsusb.py inside the VM shows USB 3.00 Host 5000Mbps with a USB 3.20 device with 5000Mbps. The same on the host:

Code: Select all

usb4              1d6b:0003 09 1IF  [USB 3.00,  5000 Mbps,   0mA] (xhci-hcd 0000:00:14.0) hub
  4-1               0424:5734 09 1IF  [USB 3.10,  5000 Mbps,   0mA] (Microchip Tech USB5734) hub
  4-5               0781:55af 00 1IF  [USB 3.20,  5000 Mbps, 896mA] (SanDisk Extreme Pro 55AF 323134385357343031333831)
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: USB 3.2 device degraded performance inside the VM

Post by fth0 »

Did you read and understand klaus' answer to your question on IRC yesterday?

For the convenience of other readers:
klaus-vb on IRC #vbox wrote:VBox offers a USB MSD emulation only, which can handle one outstanding request at a time only. providing better performance would be possible with the xHCI controller, but would need "UASP" instead of MSD as the protocol. can't you attach the device to the AHCI controller? should give better performance.
AHCI can also support hot-plugging if you configure the controller correctly.
mssm
Posts: 5
Joined: 17. Aug 2022, 12:56

Re: USB 3.2 device degraded performance inside the VM

Post by mssm »

Thanks, I may have missed that answer... going to try that.
mssm
Posts: 5
Joined: 17. Aug 2022, 12:56

Re: USB 3.2 device degraded performance inside the VM

Post by mssm »

What did he mean with "attach to a AHCI controller" ? Physically using a different port on my machine?
I have the uas module loaded on the host:

Code: Select all

# lsmod |grep uas
uas                    20480  0
usb_storage            57344  1 uas
I'm quite sure the device is running in uas mode:

Code: Select all

# grep uas /var/log/everything/current
Aug 19 07:28:41 [kernel] usbcore: registered new interface driver uas
Aug 19 13:14:24 [kernel] scsi host5: uas
mssm
Posts: 5
Joined: 17. Aug 2022, 12:56

Re: USB 3.2 device degraded performance inside the VM

Post by mssm »

You mean I should pass the physical device as SATA? That means disabling the USB pass-through, then adding a Storage->SATA->Harddrive, but how can I access my host device there?
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: USB 3.2 device degraded performance inside the VM

Post by fth0 »

I'm not sure, but I'd interpret his statements as follows:

In the VM, the virtual xHCI USB 3.0 controller only supports MSD, not UASP, leading to lower performance. In consequence, you should use a virtual AHCI controller instead, which should give better performance. On the host, you could use 9.7.1. Using a Raw Host Hard Disk From a Guest to access your USB NVMe drive (or use a VDI file on it). If you'd configure the virtual AHCI controller for hot-plugging (9.22. Oracle VM VirtualBox Expert Storage Management), it should be possible to remove the USB NVMe drive while the VM is paused.
mssm
Posts: 5
Joined: 17. Aug 2022, 12:56

Re: USB 3.2 device degraded performance inside the VM

Post by mssm »

That worked. I added an SATA type AHCI, get 460MB/s now, almost the host performance.
Is AHCI the optimum? Or should I set NVMe there as inside the USB enclosure there is an NVMe installed.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: USB 3.2 device degraded performance inside the VM

Post by scottgus1 »

mssm wrote:should I set NVMe there as inside the USB enclosure there is an NVMe installed.
The VM 'hardware' does not in any way have to match the host hardware. So you could have a DOS VM on the NVMe drive (DOS only uses IDE) and the VM will run.

Your VM can use IDE, SATA, SCSI, NVMe, etc and it will work, regardless of the physical drive the VM is stored on. A VM using NVMe for its drive connection can be stored on a spinning platter drive connected through IDE on the host and it will work. Each standard will have its own amount of overhead that the VM must calculate, and the OS inside the VM has to know how to talk through the chosen standard. So some data speed differences may occur. Aside from those, anything goes.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: USB 3.2 device degraded performance inside the VM

Post by fth0 »

In addition to what scottgus1 wrote:

Please try the virtual NVMe and SCSI controllers, and perhaps also virtio-scsi. I'd be interested to hear about your experiences.
Post Reply