Re: [PATCH] some performance improvements



updated patch attached, which fixes the use of the GConfClient, found by
Lorenzo.

On Fri, 2005-10-14 at 12:16 +0200, Rodrigo Moya wrote:
> Hi
> 
> Attached patch includes:
> 
> * part of my performance improvements, essentially the lazy startup of
> the screensaver and the typing break (1s gain as of Lorenzo's analysis
> [1]), and the async wait of children started in
> gnome_settings_daemon_spawn_with_input.
> * patch from Erwann for http://bugzilla.gnome.org/show_bug.chi?id=314774
> 
> I think this should be also committed to the 2.12 branch, ok?
> 
> [1] http://www.gnome.org/~lcolitti/gnome-startup/analysis/
> _______________________________________________
> gnomecc-list mailing list
> gnomecc-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnomecc-list
-- 
Rodrigo Moya <rodrigo novell com>
? org.gnome.SettingsDaemon.desktop-service
? org.gnome.SettingsDaemon.service
? org.gnome.SettingsDaemon.service.in
? performance-patch.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/ChangeLog,v
retrieving revision 1.193
diff -u -p -r1.193 ChangeLog
--- ChangeLog	10 Oct 2005 19:32:45 -0000	1.193
+++ ChangeLog	14 Oct 2005 13:42:20 -0000
@@ -1,3 +1,27 @@
+2005-10-14  Rodrigo Moya <rodrigo novell com>
+
+	* gnome-settings-daemon.c (child_watch_cb): added this function to
+	watch for children...
+	(gnome_settings_daemon_spawn_with_input): ...started here, instead
+	of just blocking.
+
+	* gnome-settings-screensaver.c (gnome_settings_screensaver_load): do
+	lazy loading of the screensaver.
+	(really_start_screensaver): start on a 25 seconds timeout.
+
+	* gnome-settings-typing-break.c (gnome_settings_typing_break_load): do
+	lazy loading og the typing break applet.
+	(really_setup_typing_break): start on a 30 seconds timeout.
+
+2005-10-14  Erwann Chenede <erwann chenede sun com>
+
+	Fixes #314774
+
+	* gnome-settings-xrdb.c (gnome_settings_xrdb_load): connect to
+	"notify:gtk-theme-name" signal, to run xrdb only when the whole theme
+	has been changed.
+	(theme_changed): callback for "notify:gtk-theme-name".
+
 2005-10-10  Jürg Billeter  <j bitron ch>
 
 	reviewed by: Sergey V. Udaltsov  <svu gnome org>
Index: gnome-settings-daemon.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.c,v
retrieving revision 1.37
diff -u -p -r1.37 gnome-settings-daemon.c
--- gnome-settings-daemon.c	12 Jun 2005 13:09:44 -0000	1.37
+++ gnome-settings-daemon.c	14 Oct 2005 13:42:20 -0000
@@ -446,6 +446,19 @@ wait_for_child (int  pid,
   return TRUE;
 }
 
+static void
+child_watch_cb (GPid pid, gint status, gpointer user_data)
+{
+  gchar *command = user_data;
+
+  if (!WIFEXITED (status) || WEXITSTATUS (status))
+    {
+      g_warning ("Command %s failed", command);
+    }
+
+  g_free (command);
+
+}
 
 /*
  * Helper function for spawn_with_input() - write an entire
@@ -493,6 +506,7 @@ gnome_settings_daemon_spawn_with_input (
   int child_pid;
   int inpipe;
   GError *err = NULL;
+  gchar *command;
   
   if (!g_spawn_async_with_pipes (NULL /* working directory */, argv, NULL /* envp */,
 				 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
@@ -509,25 +523,16 @@ gnome_settings_daemon_spawn_with_input (
       return;
     }
 
+  command = g_strjoinv (" ", argv);
   if (input)
     {
       if (!write_all (inpipe, input, strlen (input)))
 	{
-	  gchar *command = g_strjoinv (" ", argv);
 	  g_warning ("Could not write input to %s", command);
-	  g_free (command);
 	}
 
       close (inpipe);
     }
-      
-  wait_for_child (child_pid, &exit_status);
-
-  if (!WIFEXITED (exit_status) || WEXITSTATUS (exit_status))
-    {
-      gchar *command = g_strjoinv (" ", argv);
-      g_warning ("Command %s failed", command);
-      g_free (command);
-    }
-
+  
+  g_child_watch_add (child_pid, (GChildWatchFunc) child_watch_cb, command);
 }
Index: gnome-settings-screensaver.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-screensaver.c,v
retrieving revision 1.4
diff -u -p -r1.4 gnome-settings-screensaver.c
--- gnome-settings-screensaver.c	25 Jul 2005 11:55:59 -0000	1.4
+++ gnome-settings-screensaver.c	14 Oct 2005 13:42:20 -0000
@@ -70,25 +70,21 @@ key_toggled_cb (GtkWidget *toggle, gpoin
 	g_object_unref (client);
 }
 
-void
-gnome_settings_screensaver_load (GConfClient *client)
+static gboolean
+really_start_screensaver (gpointer user_data)
 {
 	GError *gerr = NULL;
-	gboolean start_screensaver, use_gscreensaver = FALSE;
+	gboolean use_gscreensaver = FALSE;
 	gboolean show_error;
 	GtkWidget *dialog, *toggle;
 	gchar *ss_command;
- 
-	start_screensaver = gconf_client_get_bool (client, START_SCREENSAVER_KEY, NULL);
-
-	if (!start_screensaver)
-		return;
+	GConfClient *client;
 
 	if ((ss_command = g_find_program_in_path ("gnome-screensaver")))
 		use_gscreensaver = TRUE;
 	else {
 		if (!(ss_command = g_find_program_in_path ("xscreensaver")))
-			return;
+			return FALSE;
 	}
 
 	g_free (ss_command);
@@ -98,12 +94,14 @@ gnome_settings_screensaver_load (GConfCl
 		ss_command = XSCREENSAVER_COMMAND;
 
 	if (g_spawn_command_line_async (ss_command, &gerr))
-		return;
+		return FALSE;
 	
+	client = gconf_client_get_default ();
 	show_error = gconf_client_get_bool (client, SHOW_STARTUP_ERRORS_KEY, NULL);
+	g_object_unref (client);
 	if (!show_error) {
 		g_error_free (gerr);
-		return;
+		return FALSE;
 	}
 
 	dialog = gtk_message_dialog_new (NULL,
@@ -137,5 +135,20 @@ gnome_settings_screensaver_load (GConfCl
 	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);		
 
 	gtk_widget_show (dialog);
+
+	return FALSE;
+}
+
+void
+gnome_settings_screensaver_load (GConfClient *client)
+{
+	gboolean start_screensaver;
+ 
+	start_screensaver = gconf_client_get_bool (client, START_SCREENSAVER_KEY, NULL);
+
+	if (!start_screensaver)
+		return;
+
+	g_timeout_add (25000, (GSourceFunc) really_start_screensaver, NULL);
 }
 
Index: gnome-settings-typing-break.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-typing-break.c,v
retrieving revision 1.2
diff -u -p -r1.2 gnome-settings-typing-break.c
--- gnome-settings-typing-break.c	17 Jul 2003 21:28:41 -0000	1.2
+++ gnome-settings-typing-break.c	14 Oct 2005 13:42:20 -0000
@@ -88,10 +88,16 @@ gnome_settings_typing_break_init (GConfC
   gnome_settings_daemon_register_callback ("/desktop/gnome/typing_break", typing_break_callback);
 }
 
+static gboolean
+really_setup_typing_break (gpointer user_data)
+{
+  setup_typing_break (TRUE);
+  return FALSE;
+}
 
 void
 gnome_settings_typing_break_load (GConfClient *client)
 {
   if (gconf_client_get_bool (client, "/desktop/gnome/typing_break/enabled", NULL))
-    setup_typing_break (TRUE);
+    g_timeout_add (30000, (GSourceFunc) really_setup_typing_break, NULL);
 }
Index: gnome-settings-xrdb.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-xrdb.c,v
retrieving revision 1.5
diff -u -p -r1.5 gnome-settings-xrdb.c
--- gnome-settings-xrdb.c	22 May 2005 15:46:43 -0000	1.5
+++ gnome-settings-xrdb.c	14 Oct 2005 13:42:20 -0000
@@ -321,8 +321,9 @@ apply_settings (GtkStyle *style)
 	return;
 }
 
-static void
-style_set_cb (GtkWidget *widget, GtkStyle *s, gpointer data)
+static void theme_changed (GtkSettings  *settings,
+                           GParamSpec   *pspec,
+			   GtkWidget    *widget)
 {
 	apply_settings (gtk_widget_get_style (widget));
 }
@@ -330,13 +331,25 @@ style_set_cb (GtkWidget *widget, GtkStyl
 void
 gnome_settings_xrdb_init (GConfClient *client)
 {
-	widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-	g_signal_connect (widget, "style-set", (GCallback)style_set_cb, NULL);
-	gtk_widget_ensure_style (widget);
 }
 
 void
 gnome_settings_xrdb_load (GConfClient *client)
 {
-	style_set_cb (widget, NULL, NULL);
+	static gboolean initialized = FALSE;
+
+	if (!initialized) 
+	  { /* the initialization is done here otherwise 
+	       gnome_settings_xsettings_load would generate 
+	       false hit as gtk-theme-name is set to Default in 
+	       gnome_settings_xsettings_init */
+	    GtkSettings *settings = gtk_settings_get_default ();
+	    widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+	    g_signal_connect (settings,
+			      "notify::gtk-theme-name",
+			      G_CALLBACK (theme_changed),
+			      widget);
+	    gtk_widget_ensure_style (widget); 
+	    initialized = TRUE;
+	  }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]