Opened 9 years ago

Closed 9 years ago

Last modified 3 years ago

#2184 closed patch (Fixed)

Speed optimizations to the torrentview in GTKUI

Reported by: bro Owned by:
Priority: minor Milestone: 2.0.0
Component: GTK UI Version: master
Keywords: Cc:

Description

With many torrents (hundreds), the GTKUI torrent view gets noticeably slower and slower. With around 1800 torrents, each call to update_view takes around 400-600ms on my machine, when showing all the torrents. This causes the entire thing to freeze until it's finished updating.

I've optimized the update_view method so that now, each update takes around 15-20ms when showing all torrents with sorting on the Name column, and a little less with no sorting. CPU usage when showing the All list is down from 90-100% to 4-10%

It's still quite slow to change list, e.g. from a small list (say "Downloading" with a couple of torrents), to "All" with 1800 torrents. This takes about 350-400ms on my machine.

Thats because it has to do this for most of the torrents:

row[filter_column] = True

Also loading the list when first connecting was crazy slow because of a very inefficient way of adding the rows to the liststore. Adding the rows is now down from about 3 seconds to 20-30ms.

The two most important changes for the speed increase is:

  • Test for the value row[filter_column] before setting a new value.
 if row[filter_column] is True:
   row[filter_column] = False
 if row[filter_column] is False:
   row[filter_column] = True

  • The first try/catch in the for-loop (for row in self.liststore)

Since most updates are of the same list, we now expect the torrent_id to be in the status dictionary, instead of first checking if it is.

Optimized update_view and add_rows on 1-3-stable: https://github.com/bendikro/deluge/commit/762ad783e2b4d22c74955ddd0bbe86fc13d8550f

If anyones interested, a version with time tests and prints is in the branch 1.3-dev-torrentview_time_test.

Change History (8)

comment:1 Changed 9 years ago by bro

After profiling some more I found that cell_data_trackericon was using quite a lot of time as well. After running Deluge for 38 seconds (changing lists all the time), cell_data_trackericon was using 5.2 seconds.

Reading the tracker icon from disk every time it's called is kind of slow ;-)

After adding caching of the pixbuf it's down to 1.8 seconds, running Deluge for 45 seconds. https://github.com/bendikro/deluge/commit/bb3422698670015dcc41030658a3e2e9e55b6a2f

comment:2 Changed 9 years ago by Cas

  • Milestone changed from 1.3.x to 1.3.6

comment:3 Changed 9 years ago by Cas

  • Milestone changed from 1.3.6 to 1.4.0

comment:4 Changed 9 years ago by bro

  • Version changed from git 1.3-stable to git master

Speedups for master branch: https://github.com/bendikro/deluge/commits/master-torrentview-speedups Will make a master branch for the tracker icons as well.

comment:5 Changed 9 years ago by bro

Tracker icon patch for master is here: http://dev.deluge-torrent.org/ticket/2248

comment:6 Changed 9 years ago by gazpachoking

  • Resolution set to fixed
  • Status changed from new to closed

Merged in b4f5e78a7

comment:7 Changed 6 years ago by Cas

  • Milestone changed from 2.0.x to 2.0

comment:8 Changed 3 years ago by Cas

  • Milestone changed from 2.0 to 2.0.0

Milestone renamed

Note: See TracTickets for help on using tickets.