News for hackers. Stuff that matters.
Re:Qt signal is ten times slower than a virtual function by msbarnett on Thursday August 11, 2022 @02:31PM (#32429869)
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.

Re:Qt signal is ten times slower than a virtual function by morelisp on Thursday August 11, 2022 @03:22PM (#32430501)
> 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-performa...

Re:Qt signal is ten times slower than a virtual function by spacedcowboy on Thursday August 11, 2022 @05:06PM (#32431716)
There'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-co...

Re:Qt signal is ten times slower than a virtual function by ksherlock on Thursday August 11, 2022 @04:33PM (#32431358)
Also, 30 years ago, on NeXT hardware.
Re:Qt signal is ten times slower than a virtual function by cma on Thursday August 11, 2022 @04:55PM (#32431611)
Memory latency hasn't improved that much since Next and these kind of virtual-like things cause lots of dependent reads.
Re:Qt signal is ten times slower than a virtual function by tinus_hn on Friday August 12, 2022 @09:23AM (#32438232)
Objc_msgsend on the other hand, has been optimized continuously.

https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.h...

Re:Qt signal is ten times slower than a virtual function by eska on Thursday August 11, 2022 @03:14PM (#32430378)
In a tight loop you’d resolve the dispatch only once and call the resulting function repeatedly.