--gtk-unbuffered



Hi Owen, et. al,
while trying to further identify the performance bottlenecks
in current gtk+, I've added a runtime switch to globally
disable double buffering. (See patch below, ok to commit ?).

The slowest parts - compared to the times before Pango / GObject / 
Backing Store merge are:

testgtk::message dialog :
testgtk::labels : the "normal" text rendering is relatively ok, but
	the rendering of auto-wrapped labels is at least twenty times
	slower than before. While investigating possible sollutions
	I stumbled over three functions, which all say something
	about required optimization :

	gtk_label_ensure_layout - probably called more often than needed

	pango_layout_set_width ->
	pango_layout_clear_lines : (called too often)
		/* This could be handled separately, since we don't need to
       	* recompute log_attrs on a width change, but this is easiest
       	*/
	pango_layout_get_extents(_internal) ->
	pango_layout_check_lines - 

The sequence in gtk_label_ensure_layout () calls set_with and get_extents
up to five times, which cause the pango internal log_attrs to be destroyed
and recalculated constantly although the comment above says, that it would
not be necessary to do it at all, on a width change.

I'm afraid, that I don't understand pango internals enough to fix this myself.
Could someone please take a look into it ?


testgtk::color selection :
	has a slightly unoptimized implementation, constantly recalculating 
	masks etc. The Gimp color selctor shows, how much faster this could
	be done, even on windoze :) Would a patch to improve performance be
	considered for imclusion ?

testgtk::file selection : (takes some seconds to show up in the gtk build
	directory)
	requires further investigation. My current guess is, that the
	whole file lists gets caculated (and rendered?) before showing
	the dialog.

BTW: all the testing was done on win98/233 Mhz MMX, but I'm sure the
*ix versions and other hardware platforms would benefit by the 
performance gain as well ...

Thanks in advance,
	Hans

Now for the patch :

diff --exclude-from=c:\util\tool\diff.ign -u -r from-cvs/gtk+/gtk/gtkmain.c
my-gtk/gtk+/gtk/gtkmain.c
--- from-cvs/gtk+/gtk/gtkmain.c	Sat Feb 17 18:12:26 2001
+++ my-gtk/gtk+/gtk/gtkmain.c	Sat Feb 24 22:47:44 2001
@@ -154,6 +154,8 @@
 
 #endif /* G_ENABLE_DEBUG */
 
+gboolean gtk_double_buffered = TRUE;
+
 gchar*
 gtk_check_version (guint required_major,
 		   guint required_minor,
@@ -329,6 +331,11 @@
 	      fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
 	      fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
               g_log_set_always_fatal (fatal_mask);
+	      (*argv)[i] = NULL;
+	    }
+	  else if (strcmp ("--gtk-unbuffered", (*argv)[i]) == 0)
+	    {
+            gtk_double_buffered = FALSE;
 	      (*argv)[i] = NULL;
 	    }
 #ifdef G_ENABLE_DEBUG
diff --exclude-from=c:\util\tool\diff.ign -u -r from-cvs/gtk+/gtk/gtkmain.h
my-gtk/gtk+/gtk/gtkmain.h
--- from-cvs/gtk+/gtk/gtkmain.h	Sat Feb 03 14:11:00 2001
+++ my-gtk/gtk+/gtk/gtkmain.h	Sat Feb 24 22:51:58 2001
@@ -66,6 +66,8 @@
 #define GTKMAIN_C_VAR extern
 #endif
 
+extern gboolean gtk_double_buffered;
+
 GTKMAIN_C_VAR const guint gtk_major_version;
 GTKMAIN_C_VAR const guint gtk_minor_version;
 GTKMAIN_C_VAR const guint gtk_micro_version;
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gtk+/gtk/gtkwidget.c my-gtk/gtk+/gtk/gtkwidget.c
--- from-cvs/gtk+/gtk/gtkwidget.c	Sat Feb 03 14:11:26 2001
+++ my-gtk/gtk+/gtk/gtkwidget.c	Sat Feb 24 22:46:40 2001
@@ -1021,7 +1021,7 @@
 			GTK_SENSITIVE |
 			GTK_PARENT_SENSITIVE |
 			(composite_child_stack ? GTK_COMPOSITE_CHILD : 0) |
-			GTK_DOUBLE_BUFFERED);
+			(gtk_double_buffered ? GTK_DOUBLE_BUFFERED : 0));
 
   widget->style = gtk_widget_peek_style ();
   gtk_style_ref (widget->style);

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert




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