]> granicus.if.org Git - transmission/commitdiff
(trunk gtk) companion commit to r11738 to reduce unnecessary re-rendering in the...
authorJordan Lee <jordan@transmissionbt.com>
Fri, 21 Jan 2011 17:07:23 +0000 (17:07 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Fri, 21 Jan 2011 17:07:23 +0000 (17:07 +0000)
The main window called gtk_tree_model_filter_refilter() once per second to refresh the torrent list's filtering. This is not an efficient approach: gtk_tree_model_filter_refilter() emits a "row changed" event for every row, causing unnecessary re-rendering.

I've removed the call to gtk_tree_model_filter_refilter() and expanded the model to includes all the fields necessary for filtering. That way we only fire "row changed" events for rows that actually change.

By reducing the number of renders in steady state, this might ameliorate https://bugs.launchpad.net/ubuntu/+source/transmission/+bug/655024

However it will *not* help the related "CPU spikes to 100% on scrolling" ticket at https://trac.transmissionbt.com/ticket/3887 because rendering paused torrents is still exceptionally expensive in the murrine theme.

gtk/tr-core.c
gtk/tr-core.h
gtk/tr-window.c

index a537836ce6c40fc96897d2b3dc78784ab9f308f6..30107592dd46163a1aee6445300f0c06979017c0 100644 (file)
@@ -766,7 +766,9 @@ tr_core_init( GTypeInstance *  instance,
                       G_TYPE_INT,       /* tr_stat.activity */
                       G_TYPE_UCHAR,     /* tr_stat.finished */
                       G_TYPE_CHAR,      /* tr_priority_t */
-                      G_TYPE_STRING };  /* concatenated trackers string */
+                      G_TYPE_STRING,    /* concatenated trackers string */
+                      G_TYPE_INT,       /* MC_ERROR */
+                      G_TYPE_INT };     /* MC_ACTIVE_PEER_COUNT */
 
     p = self->priv = G_TYPE_INSTANCE_GET_PRIVATE( self,
                                                   TR_CORE_TYPE,
@@ -1280,6 +1282,8 @@ update_foreach( GtkTreeModel * model,
                 gpointer       data UNUSED )
 {
     int oldActivity, newActivity;
+    int oldActivePeerCount, newActivePeerCount;
+    int oldError, newError;
     tr_bool oldFinished, newFinished;
     tr_priority_t oldPriority, newPriority;
     char * oldCollatedName, * newCollatedName;
@@ -1297,6 +1301,8 @@ update_foreach( GtkTreeModel * model,
                         MC_TORRENT, &gtor,
                         MC_NAME_COLLATED, &oldCollatedName,
                         MC_ACTIVE, &oldActive,
+                        MC_ACTIVE_PEER_COUNT, &oldActivePeerCount,
+                        MC_ERROR, &oldError,
                         MC_ACTIVITY, &oldActivity,
                         MC_FINISHED, &oldFinished,
                         MC_PRIORITY, &oldPriority,
@@ -1315,6 +1321,8 @@ update_foreach( GtkTreeModel * model,
     newTrackers = torrentTrackerString( tor );
     newUpSpeed = st->pieceUploadSpeed_KBps;
     newDownSpeed = st->pieceDownloadSpeed_KBps;
+    newActivePeerCount = st->peersSendingToUs + st->peersGettingFromUs + st->webseedsSendingToUs;
+    newError = st->error;
     inf = tr_torrent_info( gtor );
     newCollatedName = g_utf8_strdown( inf->name ? inf->name : "", -1 );
 
@@ -1324,6 +1332,8 @@ update_foreach( GtkTreeModel * model,
         || ( newActivity  != oldActivity )
         || ( newFinished != oldFinished )
         || ( newPriority != oldPriority )
+        || ( newError != oldError )
+        || ( newActivePeerCount != oldActivePeerCount )
         || gtr_strcmp0( oldTrackers, newTrackers )
         || gtr_strcmp0( oldCollatedName, newCollatedName )
         || gtr_compare_double( newUpSpeed, oldUpSpeed, 3 )
@@ -1331,6 +1341,8 @@ update_foreach( GtkTreeModel * model,
     {
         gtk_list_store_set( GTK_LIST_STORE( model ), iter,
                             MC_ACTIVE, newActive,
+                            MC_ACTIVE_PEER_COUNT, newActivePeerCount,
+                            MC_ERROR, newError,
                             MC_ACTIVITY, newActivity,
                             MC_NAME_COLLATED, newCollatedName,
                             MC_FINISHED, newFinished,
index 0bdea63dfdeeca884f2a5208eef3a90092263788..e1f89f75ca5a24ddb1c87ff31fdd08a48736b939 100644 (file)
@@ -196,6 +196,16 @@ enum
     MC_FINISHED,
     MC_PRIORITY,
     MC_TRACKERS,
+
+    /* tr_stat.error
+     * Tracked because ACTIVITY_FILTER_ERROR needs the row-changed events */
+    MC_ERROR,
+
+    /* tr_stat.{ peersSendingToUs + peersGettingFromUs + webseedsSendingToUs }
+     * Tracked because ACTIVITY_FILTER_ACTIVE needs the row-changed events */
+    MC_ACTIVE_PEER_COUNT,
+
+
     MC_ROW_COUNT
 };
 
index 805a6666cd2a38ed1da0d3ce8ba298c0d4d542a2..dce56290755e483c49f574bf010786921d1f4f5f 100644 (file)
@@ -851,7 +851,6 @@ gtr_window_refresh( TrWindow * self )
         updateSpeeds( p );
         updateTorrentCount( p );
         updateStats( p );
-        gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( p->filter_model ) );
     }
 }