Opened 11 years ago

Closed 11 years ago

#3968 closed Enhancement (fixed)

tr_cpFileIsComplete could be faster

Reported by: jordan Owned by: jordan
Priority: Normal Milestone: 2.20
Component: libtransmission Version: 2.13
Severity: Normal Keywords:
Cc:

Description (last modified by jordan)

tr_cpFileIsComplete() took up 1.77% of runtime during an overnight seeding session, putting it in the top 10 of functions using the most CPU during the session.

It's also easily refactored to require less CPU. Right now, it walks through all the blocks in a file to see if we have it. However if the file is large, that can be a lot of blocks.

If the file spans multiple pieces, we can walk block-by-block in the first and last pieces, but walk the inner ones piece-by-piece, which is faster.

In the overnight run made tr_cpIsComplete() into a wrapper function that called the old and new implementations and asserted that they returned the same value. This was the result in the profile:

     1.77%  transmission-gt  transmission-gtk                                                            [.] tr_cpFileIsCompleteOld
            |
            --- tr_cpFileIsCompleteOld
               |          
               |--100.00%-- tr_cpFileIsComplete
               |          |          
               |          |--98.93%-- tr_torrentPieceNeedsCheck
               |          |          fillOutputBuffer
               |          |          peerPulse
               |          |          |          
               |          |          |--98.70%-- tr_peerMsgsPulse
               |          |          |          pumpAllPeers
               |          |          |          bandwidthPulse
               |          |          |          event_base_loop
               |          |          |          
     0.07%  transmission-gt  transmission-gtk                                                            [.] tr_cpFileIsCompleteNew
            |
            --- tr_cpFileIsCompleteNew
                tr_cpFileIsComplete
               |          
               |--95.76%-- tr_torrentPieceNeedsCheck
               |          fillOutputBuffer
               |          peerPulse
               |          |          
               |          |--98.34%-- tr_peerMsgsPulse
               |          |          pumpAllPeers
               |          |          bandwidthPulse
               |          |          event_base_loop

Change History (3)

comment:1 Changed 11 years ago by jordan

  • Description modified (diff)

comment:2 Changed 11 years ago by jordan

  • Component changed from Transmission to libtransmission
  • Owner set to jordan
  • Status changed from new to assigned

r11797: fixed

comment:3 Changed 11 years ago by jordan

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.