Ethereal-dev: [Ethereal-dev] Conversation/Endpoint list performance patch

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Ian Schorr <ethereal@xxxxxxxxxxxxx>
Date: Tue, 13 Jul 2004 00:49:12 -0400
Hi all,

Attached are a couple of simple patches that should improve performance of the Conversation List and Endpoint List features tremendously.

In my testing I saw about 2x to over 500x improvement.

We were able to get away with the lists the way they were in GTK-1.x, but in GTK-2.x the features are nearly unusable with captures containing moderately large numbers of conversations/hosts. These patches should improve performance in both, though.

There's quite a bit more optimization that can be done, I just figured I'd hit the lowest-hanging fruit first.

Ian
--- endpoint_talkers_table.c	2004-07-13 00:36:55.033630400 -0400
+++ endpoint_talkers_table.c.bak	2004-07-13 00:36:24.589854400 -0400
@@ -225,9 +225,7 @@
     }
 
     /* remove all entries from the clist */
-    for(i=0;i<et->num_endpoints;i++){
-        gtk_clist_remove(et->table, et->num_endpoints-i-1);
-    }
+    gtk_clist_clear(et->table);
 
     /* delete all endpoints */
     for(i=0;i<et->num_endpoints;i++){
@@ -317,9 +315,11 @@
 		gtk_widget_show(col_arrows[column].descend_pm);
 		gtk_clist_set_sort_column(clist, column);
 	}
-	gtk_clist_thaw(clist);
 
 	gtk_clist_sort(clist);
+
+	gtk_clist_thaw(clist);
+
 }
 
 
@@ -1007,8 +1007,6 @@
 }
 
 
-
-/* XXX should freeze/thaw table here and in the srt thingy? */
 static void
 draw_ett_table_data(endpoints_table *et)
 {
@@ -1016,6 +1014,9 @@
     int j;
     char title[256];
 
+    /* Freeze the Endpoint table since quite a few changes will occur */
+    gtk_clist_freeze(et->table);
+
     if (et->page_lb) {
         if(et->num_endpoints) {
             g_snprintf(title, 255, "%s: %u", et->name, et->num_endpoints);
@@ -1053,6 +1054,8 @@
 
     /* update table, so resolved addresses will be shown now */
     draw_ett_table_addresses(et);
+
+    gtk_clist_thaw(et->table);
 }
 
 
@@ -1484,6 +1487,8 @@
         char *entries[NUM_COLS];
         char frames[16],bytes[16],txframes[16],txbytes[16],rxframes[16],rxbytes[16];
 
+	  /* Freeze the endpoint table while performing updates */
+        gtk_clist_freeze(et->table);
 
         /* these values will be filled by call to draw_ett_table_addresses() below */
         entries[0] = "";
@@ -1509,7 +1514,7 @@
         gtk_clist_insert(et->table, talker_idx, entries);
         gtk_clist_set_row_data(et->table, talker_idx, (gpointer) talker_idx);
 
-        draw_ett_table_addresses(et);
+        gtk_clist_thaw(et->table);
     }
 }
 
--- hostlist_table.c	2004-07-13 00:21:31.976339200 -0400
+++ hostlist_table.c.bak	2004-07-13 00:04:47.522004800 -0400
@@ -156,9 +156,7 @@
     }
 
     /* remove all entries from the clist */
-    for(i=0;i<hosts->num_hosts;i++){
-        gtk_clist_remove(hosts->table, hosts->num_hosts-i-1);
-    }
+    gtk_clist_clear(hosts->table);
 
     /* delete all hosts */
     for(i=0;i<hosts->num_hosts;i++){
@@ -243,9 +241,10 @@
 		gtk_widget_show(col_arrows[column].descend_pm);
 		gtk_clist_set_sort_column(clist, column);
 	}
-	gtk_clist_thaw(clist);
 
 	gtk_clist_sort(clist);
+
+	gtk_clist_thaw(clist);
 }
 
 
@@ -493,7 +492,6 @@
 }
 
 
-/* XXX should freeze/thaw table here and in the srt thingy? */
 static void
 draw_hostlist_table_data(hostlist_table *hl)
 {
@@ -501,6 +499,9 @@
     int j;
     char title[256];
 
+    /* Freeze the Hostlist since quite a few changes will occur */
+    gtk_clist_freeze(hl->table);
+
     if (hl->page_lb) {
         if(hl->num_hosts) {
             g_snprintf(title, 255, "%s: %u", hl->name, hl->num_hosts);
@@ -538,6 +539,8 @@
 
     /* update table, so resolved addresses will be shown now */
     draw_hostlist_table_addresses(hl);
+
+    gtk_clist_thaw(hl->table);
 }
 
 static gboolean
@@ -934,6 +937,9 @@
         char frames[16],bytes[16],txframes[16],txbytes[16],rxframes[16],rxbytes[16];
 
 
+	  /* Freeze the hostlist while performing updates */
+        gtk_clist_freeze(hl->table);
+
         /* these values will be filled by call to draw_hostlist_table_addresses() below */
         entries[0]="";
         entries[1]="";
@@ -956,7 +962,7 @@
         gtk_clist_insert(hl->table, talker_idx, entries);
         gtk_clist_set_row_data(hl->table, talker_idx, (gpointer) talker_idx);
 
-        draw_hostlist_table_addresses(hl);
+        gtk_clist_thaw(hl->table);
     }
 }