Live data from Hacker News

Why is Rosetta 2 fast?

dougallj.wordpress.com

1–10 of 367 posts

Re: Why is Rosetta 2 fast?

#2
"I believe there’s significant room for performance improvement in Rosetta 2... However, this would come at the cost of significantly increased complexity... Engineering is about making the right tradeoffs, and I’d say Rosetta 2 has done exactly that."

Re: Why is Rosetta 2 fast?

#4
I hope Rosetta is here to stay and continues developement. And I hope what is learned from it can be used to make a RISC-V version of it. translating native ARM to RISC-V should be much easier than x86 to ARM as I understand it, so one could conceivably do x86 -> ARM -> RISC-V.

Re: Why is Rosetta 2 fast?

#5
post #3

The main reason, M1/2 being incredibly fast. Is listed last.

Perhaps if you’re comparing against Intel processors, but even on an Apple Silicon Mac, Rosetta 2 vs native versions of apps are no slouch.

20% overhead for a non-native executable is very commendable.

Re: Why is Rosetta 2 fast?

#6

I hope Rosetta is here to stay and continues developement. And I hope what is learned from it can be used to make a RISC-V version of it. translating native ARM to RISC-V should be much easier than x86 to ARM as I understand it, so one could conceivably do x86 -> ARM -> RISC-V.

> I hope Rosetta is here to stay and continues developement.

It almost certainly is not. Odds are Apple will eventually remove Rosetta II, as they did Rosetta back in the days, once they consider the need for that bridge to be over (Rosetta was added in 2006 in 10.4, and removed in 2011 from 10.7).

> And I hope what is learned from it can be used to make a RISC-V version of it. translating native ARM to RISC-V should be much easier than x86 to ARM as I understand it, so one could conceivably do x86 -> ARM -> RISC-V.

That's not going to happen unless Apple decides to switch from ARM to RISC-V, and... why would they? They've got 15 years experience and essentially full control on ARM.

Re: Why is Rosetta 2 fast?

#8
Apple is doing some really interesting but really quiet work in the area of VMs. I feel like we don’t give them enough credit but maybe they’ve put themselves in that position by not bragging enough about what they do.

As a somewhat related aside, I have been watching Bun (low startup time Node-like on top of Safari’s JavaScript engine) with enough interest that I started trying to fix a bug, which is somewhat unusual for me. I mostly contribute small fixes to tools I use at work. I can’t quite grok Zig code yet so I got stuck fairly quickly. The “bug” turned out to be default behavior in a Zig stdlib, rather than in JavaScript code. The rest is fairly tangential but suffice it to say I prefer self hosted languages but this probably falls into the startup speed compromise.

Being low startup overhead makes their VM interesting, but the fact that it benchmarks better than Firefox a lot of the time and occasionally faster than v8 is quite a bit of quiet competence.

Re: Why is Rosetta 2 fast?

#9
Not having any particular domain experience here, I've idly wondered whether or not there's any role for neural net models in translating code for other architectures.

We have giant corpuses of source code, compiled x86_64 binaries, and compiled arm64 binaries. I assume the compiled binaries represent approximately our best compiler technology. It seems predicting an arm binary from an x86_64 binary would not be insane?

If someone who actually knows anything here wants to disabuse me of my showerthoughts, I'd appreciate being able to put the idea out of my head :-)

Re: Why is Rosetta 2 fast?

#10
post #3

The main reason, M1/2 being incredibly fast. Is listed last.

I don’t think that’s the main reason. The article lists a few things that, I think the main reason is that they made several parts of the CPU behave identical to x86. The M1 and M2 chips:

- can be told to do total store ordering, just as x86 does

- have of a few status flags that x86 has, but regular arm doesn’t

- can be told to make the FPU behave exactly as the x86 FPU

It also helps that ARM has many more registers than x86. Because of that the emulator can map the x86 registers to ARM registers, and have registers to spare for use by the emulator.

Post reply on HN