[Development] performance of signal slots across threads

Olivier Goffart olivier at woboq.com
Thu Feb 27 11:57:24 CET 2014


On Tuesday 25 February 2014 16:22:33 Nguyen Huu Minh wrote:
> Hi,
> 
> I am developing a cross platform application on Windows Xp embedded and on
> Ubuntu 12.04 using Qt 5.2.1. This application makes use of signal slot
> communication between QObjects living in different threads (worker and
> GUI). The separation of threads is needed because one of the QObjects
> handles the communication to a hardware device, whereas the other one
> processes data required the hardware and other components.
> 
> My main development platform is Windows and testing there show that
> everything is fine. However, compiling the same code base on Linux I notice
> very slow performance on Ubuntu due to the signal slot inter-thread
> communication. If I use the same code and same QObjects, but this time
> living in the same thread on Ubuntu, the performance is fine again.
> 
> To give you a rough idea, on Ubuntu inter-thread communication takes ~43s
> for the test code, intra-thread communication ~7s. On Windows in both case
> I get around ~6s (give or take).
> 
> I realize that using signal slots entails some overhead, I am just surprised
> by the amount the overhead it seems to create on Ubuntu and the fact that
> is overhead is almost non-existent on Windows.
> 
> Can anyone give me some insights as to why this is or solutions/workarounds
> to this phenomenon?

Hi,

It is hard to tell anything without a concrete example. 
Signals and slots itself is not platform specific, so i don't see why they 
should have different performances on different patforms. The only difference 
i can think of would be in the event loop handling.

Is your code under high contention (are both thread busy or are they waiting 
for each others?)  Maybe it is other parts of your application which is 
slower?

Perhaps could you provide a benchmark?

-- 
Olivier 

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org



More information about the Development mailing list