Amazing Rosetta and Apple Silicon success

The success of Apple Silicon M1 will be defined by how good the chip is. The success of the transition will be defined by Rosetta 2.

Apple Silicon M1

So Apple is migrating CPU architectures 1. Again. For the third time. Now from x86 (bought from Intel) to ARM:self-designed, baked by TSMC. We can all read up on their bombastic claims and decide if its good or not. Good performance? Good battery life? But bad for environment as nothing is repairable or upgradable? Everybody has an opinion. Mine? I personally think it’s an interesting, good move… but lets talk about something else.

Rosetta of 2005

Let’s draw your attention to the transition period side of things. Cast your minds back to 2005, when Apple migrated from PowerPC to x86 architecture. “How is that possible? All our software would no longer run!” – users might shout. But a key piece of technology was developed to smooth out the transition, Rosetta 2 3. It was developed by a company called Transitive, in Manchester, UK. Coincidentally, I was lucky enough to work there as well. But I joined a few years after Rosetta had been unveiled, and did not get a chance to join it’s development effort. However, for many a year Transitive remained my benchmark for an ideal workplace.

If you don’t know it’s there, its doing its job well

It is important to understand how really, really complicated that solution was. It is not only an emulator. I’ve written emulators. It wasn’t rocket science. The big brains behind the software is a real time, dynamic binary translation engine, reading in instructions from one CPU architecture, and figuring out how to produce code for another architecture altogether. Where no direct 1-to-1 mapping of such operations may even exist. Or a different amount of registers are available. Or many, many other challenges – to list most of them i would need a series of blogs. But let us review what Steve Jobs claimed in 2005:

– Dynamic Binary translation
– Runs existing Apps!
– Transparent to users
– Lightweight
– Fast (enough)

In my humble opinion, the key take-away was the last point there. It showed that Apple (Transitive) did made it work! But they wanted to downplay user expectations. Maybe they were not 100% confident?

Rosetta of 2020

Now back to the future (or rather, the present). This time we have Rosetta 2. It is no longer built by Transitive, as that has been acquired by IBM back in 2008 4. But the experts are still out there, the technology has been proven, and Apple built a new one.

The success of Apple Silicon will be defined by how good the hardware is. The success of the transition will be defined by two things: how well Rosetta 2 performs, and how fast software providers distribute updated versions of their applications. Popular tech news articles will once again briefly-or-not mention Rosetta 2, most likely calling it an emulation layer. You, my dear reader, by now should guess that it is not just that. Once again, it is an amazing solution, a complicated engine to perform difficult computational tasks, solve register and memory management issues, perform as fast as possible (or better!!), never crash, and handle anything that is thrown at it. There should be no option to fail here. No place to

log.error("TODO: finish this instruction translation later");

So… What is special about the second version 5? Let’s have a quick look at Apple developer documentation.

“If an executable contains only Intel instructions, macOS automatically launches Rosetta and begins the translation process. When translation finishes, the system launches the translated executable in place of the original. However, the translation process takes time, so users might perceive that translated apps launch or run more slowly at times,”

It’s not all powerful, Apple lists instruction set extensions and things they don’t support yet: kernel extensions, hypervisors running x86 VMs, vector instructions… But it is still fascinating. Let’s take their example: your software is already ‘new’, compiled for the ARM architecture. But it has plugins you want to use, and those are not. In theory, Rosetta 2 should be able to run the whole process ‘translated’, and handle the old plugins fine. So what did Tim Apple boast about Rosetta this time?

Notice that key differences in the presentation.

  • No longer did Apple downplay user expectations: “fast enough” vs “Fast performance”. To me it shows they have more confidence in it, and a more powerful tool at their fingertips.
  • Translated at install time: now that sounds cool. Does that mean, that if you attempt to install an x86 app, it is completely translated immediately, and you have a translated binary ready to go? That is generally called “static binary translation”, but has great limitations for code that is loaded dynamically.
  • Dynamic translation for JITs: this means they not only do static translation. They support what is called “self modifying code”, where static translation is not possible. What is the value in translating the code ahead-of-time, if the code will go and change itself?
  • Transparent to the user: now that does not change. It must still remain the most amazing software you will never see!

Most likely it has a multi-layered caching/storage solution of translated code to avoid translating the same things over and over again. But note that warning in the quote above: “…the translation process takes time, so users might perceive that translated apps launch or run more slowly at times”.
It is important to understand this. At first launch of an app, all code is encountered for the first time. So Rosetta 2 must go instruction by instruction, decode its function, check for side effects, and produce good ARM alternatives. Then cache/store the results. Then chain those together. Now this process takes time, of course, and the application may appear to run slower. But what Apple is banking on – is that their chip is actually so good that it can offset that slowdown and in the end, it is not impossible for the application to actually – at least perceptibly – run even faster than on a previous Intel based mac!

So How Fast is it, anyway?

Now, the first benchmarks are already pouring in. Just a quick shout-out – I have just purchased an HP Elitebook with a Ryzen 7 Pro 4750U CPU. I absolutely love it. But lets have a quick look at the first numbers arstechnica provided 6.

Jetstream is the broadest of the three benchmarks shown here—it combines an enormous number of JavaScript and WebAssembly benchmarks. Workloads include regex parsing, list sorting, ray tracing and (much, much) more.

  • HP Elitebook Ryzen 7 4750U Google Chrome 129.8
  • Apple M1 Mac Mini Google Chrome x86_64 93.1

.. thats a ~28 percent performance hit on a really heavy benchmark. I give it a 9 out of 10. But…

  • Apple M1 Mac Mini Google Chrome M1 Native. 156.9

… Apple, your ARM chip outperforms my brand new spanking HP laptop. You really pulled a rabbit out of the hat this time.

Disclaimer 🙂
I’m not an ‘Apple fanboy’. I have never purchased Apple products myself but actually owned some. But I am a big fanboy of amazing hardware and software. Which Rosetta 2 most definitely is. As well as M1.

  • P.S.
    Now you will be able to run iOS apps on 4k laptop displays. What?? Is your app ready for that? Maybe its time to ping your app developer teams?
  • P.P.S.
    Electron web app developers for Macs – you might want to listen up7

    Do you disagree? Was I wrong somewhere? Feel free to leave a comment or contact me personally.
  1. https://www.apple.com/mac/m1
  2. https://www.cnet.com/news/the-brains-behind-apples-rosetta-transitive
  3. https://thenextweb.com/insider/2011/10/22/how-one-of-apples-most-important-pieces-of-software-came-from-a-small-uk-startup
  4. https://www.zdnet.com/article/ibm-acquires-transitive
  5. https://developer.apple.com/documentation/apple_silicon/about_the_rosetta_translation_environment
  6. https://arstechnica.com/gadgets/2020/11/google-chrome-is-available-as-an-apple-m1-native-app-today
  7. https://medium.com/big-tech/apple-silicon-mac-is-about-to-kill-web-apps-6428e329148e

2 Comments

  1. Anonymous
    2021-02-04
    Reply

    can you do a regex test?

  2. Declan
    2020-11-28
    Reply

    What’s occurring pabs! Some of the real-world demonstrations of the M1 chip are absurdly good right! Rosetta paired with the M1 appears to translate as fast as the last gen Intel if not faster and with a fraction of the wattage! Here’s a really good comparison between the last gen 16” MBP and the new M1 13” MBP https://youtu.be/_MUTS7xvKhQ… that battery life!

    p.s. congrats on the blog! Great read!

Leave a Reply