This is what's holding me off buying one since I don't know whether to get 16 GB RAM (if it doesn't work) or 32 GB RAM (if it does work).
This is what's holding me off buying one since I don't know whether to get 16 GB RAM (if it doesn't work) or 32 GB RAM (if it does work).
Docker for Mac runs a VM, inside that VM (which is Linux for ARM) if you run an x86_64 docker image it will use qemu to emulate x86_64 and run Linux Intel ELF binaries as if they were ARM.
That means that currently using Docker on macOS if there is a native ARM version available for the docker image, it will use that, but it can and will fall back to using x86_64 docker images.
That already works as-is. There is no hardware emulation though, it is all QEMU doing the work.
Not really. On Windows you can choose if you want to run Linux binaries in a VM or native Windows containers.
Why can’t Rosetta 2 do the x86-to-ARM JIT translation inside the “Docker for Mac” VM instead of using the (presumably slower) QEMU emulation?
Or is QEMU smart enough to do the same translation that Rosetta 2 does which, if I recall correctly, only loses about 25% performance compared to native x86?
QEMU emulates a platform on the fly, it does not attempt to rewrite the code to run on ARM and cache that result. QEMU also emulates all the specific quirks of the x86_64 platform, whereas Rosetta 2 does not.
It would be neat if Apple open sourced their Rosetta 2 technology and made it more widely available, but at this time there is no option for 3rd parties to use Rosetta 2, especially from within a Linux VM.
This is not quite correct.
First, as I understand it anyways, Rosetta 2 mostly tries to run whole-binary translation on first launch, rather than starting up in JIT and caching results. It does have a JIT engine, but it's a fallback for cases which a static translation can't handle, such as self-modifying code (which is to say, any x86 JIT engine).
Second, there is some hardware! The CPU cores are always running Arm instructions, but Apple put in a couple nonstandard extensions to alter CPU behavior away from standard Arm in ways which make Rosetta 2 far more efficient.
The first is for loads and stores. x86 has a strong memory ordering model which permits very little program-visible write reordering. Arm has a weaker memory model which allows more write reordering. If you were writing something like Rosetta 2, and naively converted every memory access to a plain Arm load or store, the reorderings permitted by Arm rules would cause nasty race conditions and the like.
So, Apple put in a mode bit which causes a CPU core to obey x86 memory ordering rules. The macOS scheduler sets this bit when it's about to pass control to a Rosetta-translated thread, and clears it when it takes control back.
The second mode bit concerns FPU behavior. IEEE 754 provides plenty of wiggle room such that compliant implementations can be different enough that they produce different results from the same sequence of mathematical operations. You can probably see where this is going, right? Turns out that Arm and x86 don't always produce bit-exact results.
Since Apple wanted to guarantee very high levels of emulation fidelity, they provided another CPU mode bit which makes the FPU behave exactly like a x86 SSE FPU.