Ignore:
Timestamp:
Dec 31, 2008, 6:08:13 PM (13 years ago)
Author:
charles
Message:

(trunk libT) improve piece verification speed by providing a larger buffer, and add a mechanism to reuse it when verifying an entire torrent at once.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/verify.c

    r7404 r7559  
    6161
    6262static int
    63 checkFile( tr_torrent *    tor,
    64            tr_file_index_t fileIndex,
    65            int *           abortFlag )
     63checkFile( tr_torrent      * tor,
     64           void            * buffer,
     65           size_t            buflen,
     66           tr_file_index_t   fileIndex,
     67           int             * abortFlag )
    6668{
    6769    tr_piece_index_t i;
     
    8587        else if( !tr_torrentIsPieceChecked( tor, i ) )
    8688        {
    87             const int      wasComplete = tr_cpPieceIsComplete(
    88                 tor->completion, i );
    89 
    90             if( tr_ioTestPiece( tor, i ) ) /* yay */
     89            const int wasComplete = tr_cpPieceIsComplete( tor->completion, i );
     90
     91            if( tr_ioTestPiece( tor, i, buffer, buflen ) ) /* yay */
    9192            {
    9293                tr_torrentSetHasPiece( tor, i, TRUE );
     
    120121verifyThreadFunc( void * unused UNUSED )
    121122{
    122     for( ; ; )
     123    for( ;; )
    123124    {
    124125        int                  changed = 0;
    125126        tr_file_index_t      i;
    126         tr_torrent *        tor;
     127        tr_torrent         * tor;
    127128        struct verify_node * node;
     129        void               * buffer;
    128130
    129131        tr_lockLock( getVerifyLock( ) );
     
    142144        tr_lockUnlock( getVerifyLock( ) );
    143145
     146        tr_torinf( tor, _( "Verifying torrent" ) );
    144147        tor->verifyState = TR_VERIFY_NOW;
    145 
    146         tr_torinf( tor, _( "Verifying torrent" ) );
     148        buffer = tr_new( uint8_t, tor->info.pieceSize );
    147149        for( i = 0; i < tor->info.fileCount && !stopCurrent; ++i )
    148             changed |= checkFile( tor, i, &stopCurrent );
    149 
     150            changed |= checkFile( tor, buffer, tor->info.pieceSize, i, &stopCurrent );
     151        tr_free( buffer );
    150152        tor->verifyState = TR_VERIFY_NONE;
    151153
Note: See TracChangeset for help on using the changeset viewer.