GSignal emission optimization
- From: Lionel Landwerlin <llandwerlin gmail com>
- To: gtk-devel-list gnome org
- Subject: GSignal emission optimization
- Date: Sun, 02 Oct 2011 03:53:56 +0100
Hi all,
These days I'm mostly working with frameworks Mx and Clutter and
contributing to projects like this Media Explorer :
https://github.com/media-explorer/media-explorer
A few months ago we started to profile our application to get better
performances on devices with a more "embedded" profile (like Intel
CE4100 chipsets).
Our profiling showed up that we spend a lot of time at painting our
Clutter scene. And a considerable amount of this time is spent on
emitting paint signal in clutter actors, that are, most of the time not
connected. At the end, most of the paint signals emitted end up calling
the virtual function associated to the signal.
We do quite a lot of things when calling the g_signal_emit() function.
One of them is to transform the variable arguments of the function into
an array of GValue which can be considered as negligible when several
function are connected to a signal but is quite costly when you don't
have anything to call.
To avoid as much computation as possible during the signal emission,
Robert Bragg came up with the idea of trying to get rid of the GValue
boxing of the variable arguments of the g_signal_emit() function and
instead transfer a argument va_list directly to the marshallers. On top
of that I did some testing & improvements (around PLT symbols) with our
application.
The optimization can be deactivated at run time. And the results using
the performance test show that we double the performances of the signal
emission in the case nobody is listening to the emission.
$ G_SIGNAL_ENABLE_VAR_ARGS=0 ./performance emit-unhandled
Running test emit-unhandled
Emissions per second: 1050115
$ G_SIGNAL_ENABLE_VAR_ARGS=1 ./performance emit-unhandled
Running test emit-unhandled
Emissions per second: 2112535
It also improve performances of connected signals :
$ G_SIGNAL_ENABLE_VAR_ARGS=0 ./performance emit-handled
Running test emit-handled
Emissions per second: 804398
$ G_SIGNAL_ENABLE_VAR_ARGS=1 ./performance emit-handled
Running test emit-handled
Emissions per second: 1368504
Our work is available here (I'm open to suggestions to move it somewhere
else) :
http://git.potipota.net/cgi-bin/cgit.cgi/glib/log/?h=signal-emission-speedup
This work started on top of the glib-2-28 branch and has been rebased on
glib-2-30. I noticed that a few things have changed on the marshallers
generation. It seems quite a few signal moved on using a generic
marshaller using ffi. I haven't had the time to look at it yet. Any
information on what it does differently from old marshaller would be
appreciated.
I could like to know whether we can rework our optimization on top of it
and investigate performances as well.
Thanks,
--
Lionel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]