Skip to content

Why use macOS virtualization framework ?

Balaji Vijayakumar edited this page Mar 30, 2022 · 1 revision

macOS virtualization

The Virtualization framework provides high-level APIs for creating and managing virtual machines (VM) on Apple silicon and Intel-based Mac computers. The framework supports the Virtual I/O Device (VIRTIO) specification, which defines standard interfaces for many device types, including network, socket, serial port, storage, entropy, and memory-balloon devices.

These high level API's can be used in Objective-C or Swift programming lanugage.

QEMU

QEMU is a free and open-source emulator. It emulates the machine's processor through dynamic binary translation and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems.

If your host's (your computer) architecture matches the guest's (QEMU) architecture and is running Mac OS 10.10 or higher, then you could speed up execution to near native speed using this option: -accel hvf (This will make use of Hypervisor low level API for native speed)

Comparison

The major advantage in using Virtualization.Framework is the support for Virtio devices. QEMU support Virtio devices for other OS but not for macOS.

With support for virtio devices mac Virtualization framework provides out of the box support for devices like virtiofs, vsock.

Shared Filesystem performance

The Shared filesystem plays a major role in performance of linux subsystems.

The idea of shared filesystem is to mont the host folders inside Virtual Machines.

The below table contains comparison of mounted filesystem performance of macvz vs lima.

  • Macvz uses virtiofs device supported in Virtualization.Framework
  • Colima uses reversesshfs
  • Lima 9P uses 9p filesystem (This is in early stage)

Github repository used for testing with filesystem performance with various workloads - https://github.com/rhvgoyal/virtiofs-tests

Name Workload Macvz (BW) Macvz (IOPS) Colima (BW) Colima (IOPS) Lima 9p (BW) Lima 9p (IOPS)
dax-test seqread-psync ✔️ 30.3mb ✔️ 7774 4687kb 1171 21.9mb 5614
dax-test seqread-psync-multi ✔️ 75.5mb ✔️ 18.8k 14.3mb 3677 30.3mb 7777
dax-test seqread-mmap ✔️ 797.1mb ✔️ 199.2k 97.2mb 24.3k 21.6mb 5537
dax-test seqread-mmap-multi ✔️ 1495.1mb ✔️ 373.7k 134.0mb 33.5k 29.3mb 7508
dax-test seqread-libaio ✔️ 30.1mb ✔️ 7724 28.3mb 7261 19.3mb 4944
dax-test seqread-libaio-multi ✔️ 76.6mb ✔️ 19.1k 28.1mb 7207 28.3mb 7250
dax-test randread-psync ✔️ 32.7mb ✔️ 8389 5087kb 1271 18.3mb 4703
dax-test randread-psync-multi ✔️ 88.6mb ✔️ 22.1k 16.0mb 4106 30.3mb 7768
dax-test randread-mmap ✔️ 31.8mb ✔️ 8159 4967kb 1241 19.0mb 4884
dax-test randread-mmap-multi ✔️ 87.5mb ✔️ 21.8k 15.4mb 3951 30.2mb 7732
dax-test randread-libaio 27.2mb 6972 ✔️ 28.0mb ✔️ 7175 13.6mb 3493
dax-test randread-libaio-multi ✔️ 59.0mb ✔️ 14.7k 28.8mb 7390 26.9mb 6904
dax-test seqwrite-psync ✔️ 14.3mb ✔️ 3662 13.5mb 3464 21.2mb 5449
dax-test seqwrite-psync-multi 38.1mb 9757 ✔️ 40.5mb ✔️ 10.1k 30.2mb 7732
dax-test seqwrite-mmap ✔️ 10.7mb ✔️ 2751 5424kb 1355 0kb 0
dax-test seqwrite-mmap-multi ✔️ 30.2mb ✔️ 7756 12.1mb 3118 0kb 0
dax-test seqwrite-libaio 14.1mb 3621 ✔️ 39.8mb ✔️ 10200 20.2mb 5183
dax-test seqwrite-libaio-multi 36.3mb 9310 ✔️ 39.1mb ✔️ 10034 30.1mb 7726
dax-test randwrite-psync 9970kb 2492 ✔️ 14.2mb ✔️ 3639 10.9mb 2798
dax-test randwrite-psync-multi 20.2mb 5186 ✔️ 34.7mb ✔️ 8889 24.8mb 6351
dax-test randwrite-mmap ✔️ 7883kb ✔️ 1970 2426kb 606 0kb 0
dax-test randwrite-mmap-multi ✔️ 21.1mb ✔️ 5420 7646kb 1911 0kb 0
dax-test randwrite-libaio 9828kb 2456 ✔️ 19.7mb ✔️ 5058 8607kb 2151
dax-test randwrite-libaio-multi 20.2mb 5180 ✔️ 39.8mb ✔️ 10192 24.7mb 6331
dax-test randrw-psync ✔️ 15.7mb/5371kb ✔️ 4034/1342 3672kb/1217kb 917/304 12.2mb/4164kb 3129/1040
dax-test randrw-psync-multi ✔️ 39.9mb/13.3mb ✔️ 10234/3428 12.0mb/4181kb 3095/1045 21.6mb/7468kb 5547/1866
dax-test randrw-mmap ✔️ 9616kb/3208kb ✔️ 2403/801 2703kb/896kb 675/223 0kb/0kb 0/0
dax-test randrw-mmap-multi ✔️ 24.1mb/8312kb ✔️ 6187/2077 9129kb/3095kb 2282/773 0kb/0kb 0/0
dax-test randrw-libaio ✔️ 16.4mb/5603kb ✔️ 4205/1400 11.1mb/3799kb 2847/949 13.4mb/4563kb 3435/1140
dax-test randrw-libaio-multi ✔️ 42.5mb/14.2mb ✔️ 10.6k/3639 19.1mb/6594kb 4892/1648 19.9mb/6884kb 5108/1720

As you could see, macvz (virtiofs) outperforms other filesystem in almost all cases.

The current experimental version of Docker desktop also make use of Virtualization framework like macvz.

Clone this wiki locally