3 ms·
"They did something in their CPU to double the speed of reference counting." I wish we'd get that on x86_64 too. Especially since it seems like an obvious and
by fxtentacle 6y ago
"They did something in their CPU to double the speed of reference counting."
I wish we'd get that on x86_64 too. Especially since it seems like an obvious and easy win.
- zozbot234 6y agoRefcounting 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.
- vlovich123 6y agoInterestingly 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)
- spankalee 6y agoFor an the references to this, I haven't yet seen a description of what the optimization is. Anyone know?
- tambourine_man 6y agoIt’s much more than twice as fast. https://twitter.com/catfish_man/status/1326238434235568128?s=21 https://twitter.com/catfish_man/status/1326238434235568128?s...
- spankalee 6y agoWhat's the actual optimization though?
- tambourine_man 6y agoHave you read the tweet and thread? If so, I don’t understand what you’re asking.
- spankalee 6y agoTwitter wasn't making the relevant responses really visible. _kbh_ pointed it out
- plasma 6y agoThe 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"
- _kbh_ 6y agoI think I found the answer in this tweet. https://twitter.com/Catfish_Man/status/1326298205034696705 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"
- annilt 6y agox86 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.
- olliej 6y agoIf you read the Catfish_Man tweet, he says that even under rosetta refcounting is faster, and under rosetta M1 has TSO.