Performance in virtual machine

Haiku run quite slow in VirtualBox in Windows 10, but Windows XP is running as fast as host system, it even get higher context switching benchmark score than host system ( #15509). Is there reasons for that, maybe Haiku kernel is doing something inefficient during context switching? Or VirtualBox have some special optimizations for Windows XP?

Haiku in virtual machine speed ranking for me:

  1. VMware player, but it’s user interface is very slow.
  2. VirtualBox.
  3. Qemu HAXM.
  4. Qemu TCG.

Haiku runs much faster in VirtualBox when compiled with KDEBUG_LEVEL=0.
See also https://dev.haiku-os.org/ticket/12304.
I switched from VirtualBox to VMware Fusion several years ago because Haiku runs faster there.
However Haiku’s disk I/O is still much slower compared to Linux or Windows running as guests.

As mentioned in that ticket, Haiku nightly builds are built with KDEBUG_LEVEL=2, which enables a lot of asserts and checks that seriously impact performance. If you try a KDEBUG_LEVEL=0 build, you will see a significant performance increase.

See the ticket @Diver linked, but also see #14979 – for some unknown reason, ICI latency in VirtualBox is about 500x slower than in KVM or on bare metal, which is likely most of the problem. Why this is, we don’t know and have not investigated.

It doesn’t explain why VMware is much faster than VirtualBox. When running Haiku on real hardware of same PC, it run much faster. Windows XP also run as fast as host system in VirtualBox. If it is just optimization problem, it should have same effect on virtual machine and real hardware.

Does this problem present only with 2 or more cores? I run Haiku in virtual machine with 1 core and it is still slow.

Try disabling IO-APIC, it isn’t needed on 1 core and greatly improves IO throughput. You should be able to see on benchmarks that after it’s disabled, things are much faster. (Leaving it enabled on 1 core will have an impact IIRC but not as much as having 2 cores.)

But no, I don’t think anyone has really investigated why Haiku in VirtualBox is so slow. Considering VMware, Hyper-V, QEMU/KVM, Parallels, etc. have no such performance issues, the problem seems to be a VirtualBox bug so we just left it at that.

1 Like

I already disabled it. It is even slower when IO-APIC is enabled.

Consider that Windows XP is running near perfectly, making system run fast in VirtualBox is theoretically possible. VirtualBox is only free and open source usable virtual machine for Windows including home versions, so it support is important.

Sure, but that requires working around all sorts of weird bugs and issues VirtualBox has; performance issues are far from the only one. For instance, the NVMe devices in VirtualBox report a completely wrong value for “max_transfer_size”; all transfers above ~700KB or so fail, while it reports 2MB as the “real” limit, which makes NVMe I/O under VirtualBox extremely unstable.

Whatever the problem is, is almost certainly VirtualBox’s fault, and so I don’t have much interest in investigating. Someone else could, of course.

It claims to be free and open source, but last I heard, the provided source tarballs were insufficient to actually build a working Windows version of VirtualBox; there were missing files or something like that. But maybe this has changed recently.

Additionally, QEMU now supports using the Windows Hypervisor Platform (WHPX), so if you enable that (on Windows 10) and pass the right command line argument, QEMU will be hardware-accelerated under Windows. So, no, VirtualBox is not the only option, either.

I tried Windows Hypervisor Platform on VirtualBox and it become slower, especially framebuffer access, now it so slow that scanline update is visible. On Qemu Windows Hypervisor Platform works better than HAXM, but slower than VirtualBox without WHPX. Maybe some additional flags are needed for Qemu like disable IOAPIC?

Yes, VirtualBox does not support WHPX very well, who knows why.

I haven’t ever needed to disable IOAPIC on QEMU for performance on Linux, but it’s possible that it’s not as optimized for WHPX yet.

Question, I don’t seem to be able to compile Haiku properly on my machine. I think the problem is of-course 100% my fault, but I have been able to download and install the images with no problem.

Is it possible that the next Beta Haiku come with an image compiled with “nodebug” to compare to the “debug” version for speed and to see if it makes any difference in running some software?

The betas are compiled with KDEBUG_LEVEL=1 instead of 2 as on the nightlies, which disables most (if not all) of the options that cause significant performance impacts. So, yes, we will do this.

Thanks for letting me know.

Just FYI, VMWare is perfectly fine here. Virtual Box was OK but for I did run some tests on a “perfectly supported guest” (Ubuntu) and VMWare destroy VBox perfs in every benchmarks. Also, VBox was full of annoying bug like the Window not perfectly scaling around Ubuntu (or ElementaryOS) desktop, etc. Yep it’s free but it’s pretty buggy as well, sadly.

1 Like

Another question: what is the best virtual machine and its settings for BeOS? BeOS on VirtualBox is even slower than Haiku, context switching test give 3 digit score.

1 Like

IIRC default vesa settings contributed the most to the slowness, changing resolution in the bootloader made it much faster. See http://web.ncf.ca/au829/WeekendReports/20130309.html