News for hackers. Stuff that matters.
Re:Apple M1 vs. Ryzen 3900X vs. Intel I9 in Software Develop... by GeekyBear on Monday December 14, 2020 @02:03PM (#25421680)
There are several theories as to why the M1 does so well on on JavaScript benchmarks.

>Firestorm can do 4 FADDs and 4 FMULs per cycle with respectively 3 and 4 cycles latency. That’s quadruple the per-cycle throughput of Intel CPUs and previous AMD CPUs, and still double that of the recent Zen3, of course, still running at lower frequency. This might be one reason why Apples does so well in browser benchmarks (JavaScript numbers are floating-point doubles).

https://www.anandtech.com/show/16226/apple-silicon-m1-a14-de...

>Apple has confirmed that it’s a massive 192KB instruction cache. That’s absolutely enormous and is 3x larger than the competing Arm designs, and 6x larger than current x86 designs, which yet again might explain why Apple does extremely well in very high instruction pressure workloads, such as the popular JavaScript benchmarks.

https://www.anandtech.com/show/16226/apple-silicon-m1-a14-de...

Re:Apple M1 vs. Ryzen 3900X vs. Intel I9 in Software Develop... by Reason077 on Monday December 14, 2020 @02:40PM (#25422168)
> "There are several theories as to why the M1 does so well on on JavaScript benchmarks."

A major reason it does so well is the native Javascript support added in ARMv8.3-A.

Specifically, FJCVTZS (Floating-point Javascript Convert to Signed fixed-point, rounding toward Zero)[1] which is a Javascript-specific variant of FCVTZS implementing the overflow and exception handling behaviour that Javascript wants.

Javascript needs to do these conversions a lot, since it doesn't have integer types, and it's much faster to have it implemented in silicon rather than using the old instructions and having to handle the overflow/error checking.

[1] https://developer.arm.com/documentation/100076/0100/a64-inst...

Re:Apple M1 vs. Ryzen 3900X vs. Intel I9 in Software Develop... by GeekyBear on Monday December 14, 2020 @03:02PM (#25422465)
People who were looking for a root cause of the iOS JavaScript performance advantage have been pointing to that instruction as "the" reason before it was even used by Safari.

https://mobile.twitter.com/saambarati/status/104920213252247...

I'm sure it doesn't hurt, but the performance advantage predates the instruction's use.

Here's another theory.

>Finally doing perf counters on a dedicated test bench... 9900K having 60% worse branch misprediction than Apple's A12.

https://twitter.com/andreif7/status/1307420010177007625

Re:Apple M1 vs. Ryzen 3900X vs. Intel I9 in Software Develop... by marmaduke on Monday December 14, 2020 @03:39PM (#25422959)
the second theory seems better in my experience. I pulled a few js benchmarks and ran on native Safari on m1 vs rosetta2 node and the rosetta2+node is significantly faster, suggested the instruction set is not the key.
Re:Apple M1 vs. Ryzen 3900X vs. Intel I9 in Software Develop... by gpderetta on Monday December 14, 2020 @04:09PM (#25423349)
As far as I understand that instruction is needed to get x86 FP semantics on ARM. I.e it doesn't make JS faster but just not as slow as it would otherwise be.

Also apparently most JS engines do not actually use the FP unit but can do most computations on the integer units (unless is really FP math) which normally have much lower latency (but also lower bandwidth).

Re:Apple M1 vs. Ryzen 3900X vs. Intel I9 in Software Develop... by cesarb on Monday December 14, 2020 @03:01PM (#25422436)
I've been thinking about the instruction cache of the M1 lately.

Another difference between x86 and ARM is that, for historical reasons, on x86 there is no need to invalidate the instruction cache explicitly when writing instructions to memory. That is, on x86, when a core writes to memory, the corresponding line in the instruction cache has to be invalidated. Since the instruction cache is usually VIPT for performance reasons, it has to be indexed only by bits which don't change in the virtual to physical mapping, otherwise there's a risk of cache aliases. For an instruction cache, an alias should not be a problem (it just wastes space with duplicated data), except that all aliases have to be flushed when invalidating by physical address.

IIRC, in 64-bit ARM user space (EL0) the only available instruction to invalidate the instruction cache is an "invalidate by virtual address" instruction. Since calling that instruction (after calling an instruction to flush the data cache to the point of unification) is required on ARM, there's no need to be able to invalidate all aliases of a physical address, like would be required on x86. That means it would be easier on ARM to have much larger instruction caches than on x86.