From: Ryan Lortie Date: Thu, 21 Feb 2013 17:48:04 +0000 (+0000) Subject: gsignal: remove some pointless locking X-Git-Tag: 2.37.1~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d1d49177bc577e4c0d4ec2d73b96db09e4d5be3;p=platform%2Fupstream%2Fglib.git gsignal: remove some pointless locking We previously hold a lock in the loop that collects the arguments for g_signal_emit(), which we drop before calling into the argument collection functions and reacquire again at the bottom of the loop (ie: one release/acquire pair for each argument collected). To make matters worse, the lock is just released again after the loop. Presumably that was done to protect the access to the parameter array, but it's pretty unlikely that this is needed because the only way it changes is if the signal is unloaded. That only happens when unloading types which is quite unlikely to happen while we are emitting on an instance of that type (and, as an aside, never happens anymore anyway). If we move the unlock below the loop up above it and remove the acquire/release pair from the loop, we improve performance in the new arg-collecting performance tests by ~15% (more like ~18% in the case where we only emit to one handler -- where argument collection dominates more). https://bugzilla.gnome.org/show_bug.cgi?id=694380 --- diff --git a/gobject/gsignal.c b/gobject/gsignal.c index f4686bd..7fb98b5 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -3286,6 +3286,7 @@ g_signal_emit_valist (gpointer instance, return; } } + SIGNAL_UNLOCK (); n_params = node->n_params; signal_return_type = node->return_type; @@ -3299,7 +3300,6 @@ g_signal_emit_valist (gpointer instance, GType ptype = node->param_types[i] & ~G_SIGNAL_TYPE_STATIC_SCOPE; gboolean static_scope = node->param_types[i] & G_SIGNAL_TYPE_STATIC_SCOPE; - SIGNAL_UNLOCK (); G_VALUE_COLLECT_INIT (param_values + i, ptype, var_args, static_scope ? G_VALUE_NOCOPY_CONTENTS : 0, @@ -3317,9 +3317,7 @@ g_signal_emit_valist (gpointer instance, return; } - SIGNAL_LOCK (); } - SIGNAL_UNLOCK (); instance_and_params->g_type = 0; g_value_init (instance_and_params, G_TYPE_FROM_INSTANCE (instance));