Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5199 closed Enhancement (fixed)

tr_sessionGetNextQueuedTorrent() can be faster

Reported by: jordan Owned by: jordan
Priority: Normal Milestone: 2.80
Component: libtransmission Version: 2.75
Severity: Normal Keywords:


tr_sessionGetNextQueuedTorrent() walks through all the torrents to get their queue positions. This is done in a loop, once per free queue slot.

This can be expensive if tr_sessionCountQueueFreeSlots() or tr_session.torrentCount are high. It would be better if the get-next func returned N torrents to avoid redundant walking and position calculations.

Attachments (1)

session.h.patch (599 bytes) - added by JJTagy 9 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 9 years ago by jordan

  • Status changed from new to assigned

Added in r13708, r13709

comment:2 Changed 9 years ago by jordan

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

comment:3 Changed 9 years ago by jordan

r13710: fix r13709 oops

Changed 9 years ago by JJTagy

comment:4 follow-up: Changed 9 years ago by JJTagy

May also want to change header file (attached)

comment:5 Changed 9 years ago by jordan

Looks like this knocked ~7% off the runtime in my tests. My test session had a large number of torrents, so in the average case the improvement would probably be smaller.

Before the change:

     8.71%  transmission-da  transmission-daemon    [.] tr_torrentNext
            --- tr_torrentNext
               |--91.32%-- tr_sessionGetNextQueuedTorrent
               |          queuePulse
               |          bandwidthPulse
               |          event_base_loop

And after:

     1.42%  transmission-da  transmission-daemon    [.] tr_torrentNext
            --- tr_torrentNext
               |--88.30%-- tr_sessionGetNextQueuedTorrents
               |          queuePulse
               |          bandwidthPulse
               |          event_base_loop

comment:6 in reply to: ↑ 4 Changed 9 years ago by x190

Replying to JJTagy:

May also want to change header file (attached)

Fixed in r13711.

Note: See TracTickets for help on using tickets.