3 ms·
Objective-C was doing sufficiently-fast UI updates for it to run well on iPhones 10 years ago, while relying on objc_msgsend, which is _much_ slower than a virt
by msbarnett 4y ago
Objective-C was doing sufficiently-fast UI updates for it to run well on iPhones 10 years ago, while relying on objc_msgsend, which is _much_ slower than a virtual function call or even a Qt signal.
You wouldn't want to use ObjC's message sending OR Qt's signalling mechanism in a tight inner loop – hell, you probably don't want to deal with the indirection of the vtable incurred by a virtual function in a tight inner loop. But all of these are more than fast enough for interactive UI work.
- eska 4y agoIn a tight loop you’d resolve the dispatch only once and call the resulting function repeatedly.
- morelisp 4y ago> objc_msgsend, which is _much_ slower than a virtual function call or even a Qt signal. objc_msgsend is slower than a virtual function, but like 1.1x-2x, not 10x. (In rare cases it can even be faster due to it being a little more predictor-friendly.) https://www.mikeash.com/pyblog/friday-qa-2016-04-15-performance-comparisons-of-common-operations-2016-edition.html https://www.mikeash.com/pyblog/friday-qa-2016-04-15-performa...
- ksherlock 4y agoAlso, 30 years ago, on NeXT hardware.
- cma 4y agoMemory latency hasn't improved that much since Next and these kind of virtual-like things cause lots of dependent reads.
- tinus_hn 4y agoObjc_msgsend on the other hand, has been optimized continuously. https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.h...
- spacedcowboy 4y agoThere's a chart of various timings here [1] and objc_msgSend is actually pretty efficient (it's received a lot of optimization over the years for obvious reasons). A cached IMP is faster than a C++ virtual method call (both of which are slower than a non-virtual method call, inline code, or a C function call of course). [1] https://www.mikeash.com/pyblog/performance-comparisons-of-common-operations.html https://www.mikeash.com/pyblog/performance-comparisons-of-co...