Live data from Hacker News

Apple CPU tricks: memory reordering, JavaScript support, ref counting

twitter.com

51–60 of 196 posts

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#51
It’s important to note that most of the things mentioned here are just “tricks”: they’re fun to discover and talk about, but they really only end up being minor wins in practice. TSO is great…if you are trying to make a simpler Rosetta (it’s not even necessary on the M1, although I think Apple is still using it for convenience; I’m still trying to find out where). The JavaScript instruction speeds up…one specific rounding in JavaScript. Fast atomics help…if you’re that one specific part of Apple’s runtime that has taken advantage of it yet. They are all cool, important little optimizations, and I’m sure that few other companies could do what Apple is doing in this space.

However, it’s very much not true that Apple is “cheating” their way to performance with a bunch of these tricks for their own software (as much as you can call this cheating). Their processors are optimized for general-purpose workloads, and blow everything else out of the water even if you’re doing something profoundly “un-specialized” like run Photoshop or a Linux VM.

It’s easy to come up with takes like these that point at buzzwords that you’ve seen being thrown around in the last couple weeks in an attempt to explain this chips. The reality is that the reasons these chips are fast are either unknown or boring. I suspect that these will one out as we play around with them more, but we don’t have the details right now.

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#52
Quick note: the magic "help JS function" is literally just a double->int conversion that uses the x86 sentinel values and rounding modes. The effect on JS is that it removes a set of branches following ((int)someDouble) that are needed to match the x86 semantics that JS mandates. The instruction is not magically faster than x86. In fact more or less by definition it's just doing what x86 does.

I am tired of people bringing up that instruction as though it's magically making JS faster compared to intel. At best it's a leveling the playing field instruction.

Implementing TSO isn't "cheating", it's hard work that other companies aren't willing to do.

Ref counting isn't magically faster than other GC methods - there's arguments that it is slower - it does however use much less memory than pretty much any other GC scheme, hence the lower memory needs on iOS vs Android.

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#53
post #44

> 4/ So Apple simply cheated. They added Intel's memory-ordering to their CPU. When running translated x86 code, they switch the mode of the CPU to conform to Intel's memory ordering. Uh, no. Implementing TSO in a highly performant way is not "cheating", it's a difficult engineering feat. And no, TSO is not some fancy Intel thingy. It's a standard memory model.

i believe in this case cheating is being used to mean that they were clever, working around the problem, not doing anything wrong

Yeah. "How do we make the Wii run Game Cube games? We cheat by putting a Game Cube in the Wii!"

It's a playful use of the term.

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#54

It’s important to note that most of the things mentioned here are just “tricks”: they’re fun to discover and talk about, but they really only end up being minor wins in practice. TSO is great…if you are trying to make a simpler Rosetta (it’s not even necessary on the M1, although I think Apple is still using it for convenience; I’m still trying to find out where). The JavaScript instruction speeds up…one specific rou…

I believe with regards to TSO, it is actually a huge benefit performance wise. Without you would need to effectively have a barrier after every memory operation ARM, reducing performance drastically.

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#55
post #54

It’s important to note that most of the things mentioned here are just “tricks”: they’re fun to discover and talk about, but they really only end up being minor wins in practice. TSO is great…if you are trying to make a simpler Rosetta (it’s not even necessary on the M1, although I think Apple is still using it for convenience; I’m still trying to find out where). The JavaScript instruction speeds up…one specific rou…

I believe with regards to TSO, it is actually a huge benefit performance wise. Without you would need to effectively have a barrier after every memory operation ARM, reducing performance drastically.

Implementing the memory ordering in hardware is a huge performance benefit, but they didn’t have to do it with a switch like they have right now. ARMv8.4-RCpc would be enough, and I believe M1 supports these too.

(FWIW, Rosetta itself does “cheat”: the translated code and the runtime shares an address space, and memory accesses are not checked, so it’s possible to write an “Intel” binary that is aware of the runtime and can read emulator state.)

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#56

It’s important to note that most of the things mentioned here are just “tricks”: they’re fun to discover and talk about, but they really only end up being minor wins in practice. TSO is great…if you are trying to make a simpler Rosetta (it’s not even necessary on the M1, although I think Apple is still using it for convenience; I’m still trying to find out where). The JavaScript instruction speeds up…one specific rou…

People won’t believe it’s not Apple its magic sauce and ARM is really just that good until ARM processors start being a mainstream thing in Windows laptops. ARM its ARM-X already looks pretty juicy and the follow-ups are sure to get better and better.

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#57
post #56

It’s important to note that most of the things mentioned here are just “tricks”: they’re fun to discover and talk about, but they really only end up being minor wins in practice. TSO is great…if you are trying to make a simpler Rosetta (it’s not even necessary on the M1, although I think Apple is still using it for convenience; I’m still trying to find out where). The JavaScript instruction speeds up…one specific rou…

People won’t believe it’s not Apple its magic sauce and ARM is really just that good until ARM processors start being a mainstream thing in Windows laptops. ARM its ARM-X already looks pretty juicy and the follow-ups are sure to get better and better.

It’s Apple, not ARM.

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#58

Is the ARM ISA fundamentally faster than x86? If the underlying architectures are converging as described, it kinda seems that the difference between the two instruction sets are more legal than technical.

x86, as a legacy architecture, has a lot of baggage and complexity and takes more space and energy to decode and translate instructions to micro-ops. Also because it was not designed as a RISC arch, but rather "backported" as one, it misses out on some RISC advantages.

This is why you don't see Intel being competitive in low power applications where ARM excels.

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#59

Finally a company has the guts to move us from the straitjacket of x86. I hope this is just the beginning of much needed innovation in CPU architecture. Due to the MS/Intel duopoly we had to suffer x86 for decades with few real options.

2020 is finally the year of RISC on the desktop

Re: Apple CPU tricks: memory reordering, JavaScript support, ref counting

#60

It’s important to note that most of the things mentioned here are just “tricks”: they’re fun to discover and talk about, but they really only end up being minor wins in practice. TSO is great…if you are trying to make a simpler Rosetta (it’s not even necessary on the M1, although I think Apple is still using it for convenience; I’m still trying to find out where). The JavaScript instruction speeds up…one specific rou…

The JS rounding mode instruction wasn't even Apple's invention, it's standard ARMv8.

But yes, Apple spends a lot on CPU design and it shows; ARM's Cortex performance for things like NEON is way, way worse.

Post reply on HN