4 ms·
Slight correction: Swift‘s ARC is not a GC (the compiler just inserts retain/release calls where it’s necessary), and one can write very performant code by stee
by manmal 4y ago
Slight correction: Swift‘s ARC is not a GC (the compiler just inserts retain/release calls where it’s necessary), and one can write very performant code by steering clear of reference counted types, and Objective-C types (dynamic dispatch is really slow). Value types with copy-on-write shouldn’t impose much overhead. Automatic inlining is progressing nicely AFAIK, and recently introduced concurrency can collapse callstack frames (not sure Rust does that).
- pjmlp 4y agoIt is definitely one per CS definition of automatic memory mangement algorithms. Compiler optimizations are exactly that, optimizations that any automatic memory mangement implementation usually takes advantage of.
- manmal 4y agoI stand corrected, thanks!
- lapcat 4y ago> dynamic dispatch is really slow This is false. People believe it on faith without measuring: https://mikeash.com/pyblog/friday-qa-2016-04-15-performance-comparisons-of-common-operations-2016-edition.html https://mikeash.com/pyblog/friday-qa-2016-04-15-performance-...
- manmal 4y agoI have never used IMP caching, and don't think the average developer uses this (aside from indirect use of Apple's frameworks). Otherwise: > A normal Objective-C message send is a bit slower, as we'd expect. Still, the speed of objc_msgSend continues to astound me. Considering that it performs a full hash table lookup followed by an indirect jump to the result, the fact that it runs in 2.6 nanoseconds is amazing. That's about 9 CPU cycles. In the 10.5 days it was a dozen or more, so we've seen a nice improvement. To turn this number upside down, if you did nothing but Objective-C message sends, you could do about 400 million of them per second on this computer. So it's 9 cycles vs what, one?
- lapcat 4y ago> So it's 9 cycles vs what, one? I'm not sure what you're asking? What are you trying to compare?
- manmal 4y agoI’m comparing a message send with a statically linked function call (or inlining, as mentioned by sibling comment).
- lapcat 4y agoThis has the feel of premature optimization. These are the fastest operations. Their running time starts to get overwhelmed by the slower operations as you go down the list of things tested. Making the fastest operations a few times faster doesn't necessarily have any noticeable effect on your program.
- manmal 4y agoYou made me think, thanks for your input. I agree that it’s not a big or unsolvable problem.
- jshier 4y agoOr 0, given not using dynamic dispatch allows for inlining or even the compiler optimizing the call away entirely.