Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by spankalee on Friday November 27, 2020 @07:10PM
(#25233802)
For an the references to this, I haven't yet seen a description of what the optimization is. Anyone know?
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by _kbh_ on Friday November 27, 2020 @07:42PM
(#25234014)
I think I found the answer in this tweet.
https://twitter.com/Catfish_Man/status/1326298205034696705
Heres a snipped quote.
"this further improvement is because uncontended acquire-release atomics are about the same speed as regular load/store on A14"
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by annilt on Friday November 27, 2020 @09:11PM
(#25234539)
x86 has total store order, all stores are queued(store buffer) in the CPU and then pushed to the cache subsystem. Last item has to wait previous ones. Arm doesn’t have TSO, so CPU can reorder stores in the queue or issue stores out of order etc. depending on memory barrier use.
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by olliej on Friday November 27, 2020 @09:52PM
(#25234800)
If you read the Catfish_Man tweet, he says that even under rosetta refcounting is faster, and under rosetta M1 has TSO.
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by tambourine_man on Friday November 27, 2020 @07:36PM
(#25233971)
It’s much more than twice as fast.
https://twitter.com/catfish_man/status/1326238434235568128?s...
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by spankalee on Friday November 27, 2020 @07:41PM
(#25234001)
What's the actual optimization though?
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by plasma on Friday November 27, 2020 @08:03PM
(#25234158)
The tweet author in the linked thread later writes:
"Weaker memory model makes acquire-release atomics possible to implement much more efficiently, in exchange for not hiding some classes of multithreading bugs"
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by tambourine_man on Friday November 27, 2020 @07:48PM
(#25234053)
Have you read the tweet and thread? If so, I don’t understand what you’re asking.
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by spankalee on Friday November 27, 2020 @09:24PM
(#25234621)
Twitter wasn't making the relevant responses really visible. _kbh_ pointed it out
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by zozbot234 on Friday November 27, 2020 @07:08PM
(#25233784)
Refcounting in a single-threaded context is extremely quick and efficient. What's expensive is atomic reference counting, as seen e.g. in C++ shared_ptr<> and Swift ARC.
Re:Apple CPU tricks: memory reordering, JavaScript support, ...
by vlovich123 on Friday November 27, 2020 @10:55PM
(#25235130)
Interestingly the Twitter thread is saying uncontended atomic operations are generally as fast as non-atomic, so I don’t think the weaker memory model is the totality of the reason.
Another thing is apparently their branch predictor is specially tuned to work with how Objective-c dispatch works (which iirc Swift inherits in places too, and not just when interfacing with Obj-C APIs)
I wish we'd get that on x86_64 too. Especially since it seems like an obvious and easy win.