Speed Up AMD64(Intel) VMs on ARM(M1 Mac) Host
Tags: devops, linux, macbook
Published: 2022-10-24 17:08:56

---
title: Speed Up AMD64(Intel) VMs on ARM(M1 Mac) Host
published: true
date: 2022-10-24 07:08:56 UTC
tags: devops,linux,macbook
canonical_url: https://avilpage.com/2022/10/speedup-amd64-containers-on-arm.html
---

#### Introduction

From 2020, Apple has transitioned from Intel to ARM based Apple Silicon M1. If we run `uname -mp` on these devices, we can see the CPU architecture details.

```
$ uname -mp
arm64 arm

```

Let's run the same command on a device using Intel x86 processor.

```
$ uname -mp
x86_64 x86_64

```

Many popular docker images<sup id="fnref:dhub"><a href="https://avilpage.com/2022/10/speedup-amd64-containers-on-arm.html#fn:dhub">1</a></sup> doesn't have ARM64 support yet. When setting up a dev environment in M1 Mac, there are high chances that we stumble on these containers if we are using plain docker or ARM64 VM. So, there is a need to spin up x86\_64 VMs.

In this article, lets see how the performance affects when running a cross architecture containers and how to speed it up.

#### Setup

Lima<sup id="fnref:lima"><a href="https://avilpage.com/2022/10/speedup-amd64-containers-on-arm.html#fn:lima">2</a></sup> can run foreign architecture(x6\_64) VMs on Mac. Let's install lima, start a AMD64 VM & ARM64 VM and install k3s<sup id="fnref:k3s"><a href="https://avilpage.com/2022/10/speedup-amd64-containers-on-arm.html#fn:k3s">3</a></sup> in them. k3s will run multiple process in the background and let's see how resource consumption varies in these VMs.

```
$ brew install lima

$ limactl start linux_arm64
$ limactl start linux_amd64

```

When starting a VM, we can edit `arch` parameter in the configuration. Once VM starts, we can see the details by running `limactl list`.

```
$ limactl list
NAME ARCH
linux_amd64 x86_64
linux_arm64 aarch64

```

Lets login to each VM & install k3s.

```
$ limactl shell linux_arm64

$ curl -sfL https://get.k3s.io | sh -


$ limactl shell linux_amd64

$ curl -sfL https://get.k3s.io | sh -

```

If we look at resource consumption on the host machine, x86\_84 VM is using way more resources than ARM64 VM. This is because of the emulation layer that is running on top of the VM.

![](https://avilpage.com/images/arch-arm-docker.png)

We can login to individual VMs, run `top` to see the load average as well.

#### Fast Mode

`lima` provides `fast-mode` option for cross architecture VMs which will speed up the performance.

For that, we need to log in to VMs and install emulators.

```
$ sudo systemctl start containerd
$ sudo nerdctl run --privileged --rm tonistiigi/binfmt --install all

```

After that we can restart the VMs and monitor the resource consumption. On an average, we can see that the resource consumption is reduced by 50%.

#### Conclusion

In this article, we saw how to run cross architecture VMs on M1 Mac and how to speed up the performance. We can use this technique to run cross architecture containers on Linux as well.

* * *

1. [https://hub.docker.com/search?q=&page=10](https://hub.docker.com/search?q=&page=10) [↩](https://avilpage.com/2022/10/speedup-amd64-containers-on-arm.html#fnref:dhub "Jump back to footnote 1 in the text")

2. [https://github.com/lima-vm/lima](https://github.com/lima-vm/lima) [↩](https://avilpage.com/2022/10/speedup-amd64-containers-on-arm.html#fnref:lima "Jump back to footnote 2 in the text")

3. [Install k3s on Mac M1](https://avilpage.com/2022/10/local-kubernetes-with-k3s-on-mac.html) [↩](https://avilpage.com/2022/10/speedup-amd64-containers-on-arm.html#fnref:k3s "Jump back to footnote 3 in the text")