[Interest] Custom QAbstractEventDispatcher - changes in Qt sources
izowiuz at gmail.com
Mon Feb 3 22:00:22 CET 2020
Last email was probably eaten by hungry mailing list - resending it just in
I had some time to do more tests experimenting with custom event
To give more background, my use case is as follows:
1. There is one main thread - 'Server' - that currently contains
QWebSocketServer instance serving data to clients
2. There is one or more threads doing some additional work - 'Rooms'
Every client sends some data to server with frequency of 20Hz, by first
passing custom QEvent from Room thread to Server thread.
Server sends some data to every client with frequency of 20Hz.
Typically there are around 1-8 clients per server instance.
The goal was to check if I could 'speed it up' a bit by subclassing
QAbstractEventDispatcher and integrating libuv into my stack.
Some modifications were made to the sources of Qt:
1. As suggested by Thiago Macieira I have added to the
This allowed me to have finer control over when I want to destroy internal
liuv poll handlers and when I just want enable or disable them.
2. I have added small helper to the QSocketNotifier - a C-like, void*
handler to which I'm able to 'attach stuff'.
While not very pretty it allows me to completely remove parts of the code
that are responsible for bookkeeping relations between sockets and libuv's
VTune data from my 'production-like' server [ 1x2GHz vCore, 1GB RAM on OVH
cluster ] is here:
Generally it is looking nice. I was able to shave 15% - 20% total CPU time
on Server thread just by swapping dispatchers.
For some odd reason Room thread is now about 140% slower - but hey, never
said it was bug free solution :P
Thiago Macieira wrote:
> The one thing to look after is that QAbstractSocket has a shortcut to skip
> some of the signal-slot mechanisms of QSocketNotifier and be notified
> immediately by way of a virtual. So there's a second place to deal with
> registering/unregistering, aside from QSocketNotifier.
For the love of God I can't find it. Do I understand correctly, that I
should look for another place that call register / unregister
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest