Apple announced at the WWDC 2020 about their plan to transition the MacBook and Mac lines of products from Intel Processors to Apple Silicon (ARM) Processors. While Apple did say that they would continue to produce Intel-based Macs for “years to come”, it’s quite clear that the future belongs to ARM. Who would not want a chip that delivers better performance, dissipates less heat, and consumes low power? The question that arises in my mind is that in the two year transition period, the existing Mac applications built with the x86 architecture in mind will continue to work on the newer Apple Silicon Macs through Rosetta 2.
Rosetta 2 is included as of macOS Big Sur to aid in Apple’s transition to ARM processors from Intel processors. In addition to the just-in-time (JIT) translation support available in Rosetta, Rosetta 2 includes support for translating a application at installation time effectively creating a Universal 2 application.
https://en.wikipedia.org/wiki/Rosetta_(software)#Rosetta_2
Seeing the A12Z Bionic smoothly run Maya or Shadow of the Tomb Raider (applications built for Intel Macs) is undoubtedly exciting. However, the missing charts and benchmarks fail to give us an accurate estimate of what performance we can express. It is, however, easier to estimate the kind of performance to expect based on how well such emulators performed in the past. That’s right; this is not the first time someone is trying to do this. Apple themselves did this already with Rosetta (2006) when they initially migrated to Intel from their then PowerPC based architecture.Even Microsoft has managed to run Windows 10 on ARM PCs in 2018.
According to Apple, applications with heavy user interaction but low computational needs (such as word processors) are well suited to translation via Rosetta, while applications with high computational needs (such as AutoCAD, games, or Adobe Photoshop) are not.
https://en.wikipedia.org/wiki/Rosetta_(software)
Reading this isn’t exactly reassuring. If application with high computational needs weren’t suitable for translation via Rosetta back then, what makes Apple so confident? The answer is quite simple. Back in the day, most of the computation was carried out solely by the CPU. Thus, adding a translation layer on high computation tasks was likely to add an overhead and, in the long run, prove detrimental to the system’s performance. What changed? Enter the GPU. It’s widespread these days to offload computational tasks to the GPU. Many applications like AutoCAD, Games, or Photoshop unstable for translation back in the day are using GPU for most heavy lifting today. It is a serious advantage for the translation process.
Let’s analyse an example to understand the process better. Consider the following C program:
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
It’s the simplest program ever! Let’s see what happens when we compile this program.
Compiled on Intel x86_64
.LC0:
.string "Hello, World!"
main:
push rbp
mov rbp, rsp
mov edi, OFFSET FLAT:.LC0
mov eax, 0
call printf
mov eax, 0
pop rbp
ret
Compiled on ARM 64
.LC0:
.string "Hello, World!"
main:
stp x29, x30, [sp, -16]!
mov x29, sp
adrp x0, .LC0
add x0, x0, :lo12:.LC0
bl printf
mov w0, 0
ldp x29, x30, [sp], 16
ret
Analysing the assembly code produced by compiling the program, it is easy to notice that even though every instruction is different on both the architectures, there is still one thing common: the call to the printf function.
For this demo, consider printf to be more complex like an OS call that draws the window to render your application; or a request to the GPU to render a complex, multi-layered scene. This function call remains the same. Consider this: the only thing that is changing is the processor. The macOS Big Sur runs natively on ARM, so all the OS calls are available to all the programs in native ARM assembly. For heavy processing, we are relying on the GPU, which stays the same. Herein lies the key to the performance claims made by Apple.
It also helps that Apple is in complete control of the hardware, both the existing Intel-based and the new ARM-based. Thus the translation process can be optimised to allow Rosetta 2 to deliver maximum performance.
TL;DR
Conclusion
- Apple’s experience in building Rosetta in 2006 will undoubtedly help when it comes to building Rosetta 2.
- macOS is already running natively on Apple Silicon, meaning any libraries being used by applications today will benefit from native performance.
- Most CPU intensive tasks these days are offloaded to the GPU, which will likely be the case. This will not affect the CPU migration.
- Apple has complete control over the existing and future hardware that allows them to optimise their software to a level that no other company can.