Changeset 10553


Ignore:
Timestamp:
Apr 30, 2010, 12:27:15 AM (11 years ago)
Author:
charles
Message:

(trunk libT) #2551: "when uploading to peers, prefetch local data from disk" -- commit jch patch #1, to prefetch when a block is requested. I was surprised, but when measuring io time with and without this patch, it *is* an improvement...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-msgs.c

    r10506 r10553  
    12061206
    12071207static void
     1208prefetchPieces( tr_peermsgs *msgs )
     1209{
     1210    int i;
     1211
     1212    /* Maintain 12 prefetched blocks per unchoked peer */
     1213    for( i=msgs->prefetchCount; i<msgs->peer->pendingReqsToClient && i<12; ++i )
     1214    {
     1215        const struct peer_request * req = msgs->peerAskedFor + i;
     1216        tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length );
     1217        ++msgs->prefetchCount;
     1218    }
     1219}
     1220
     1221static void
    12081222peerMadeRequest( tr_peermsgs *               msgs,
    12091223                 const struct peer_request * req )
     
    12271241        allow = TRUE;
    12281242
    1229     if( allow )
     1243    if( allow ) {
    12301244        msgs->peerAskedFor[msgs->peer->pendingReqsToClient++] = *req;
    1231     else if( fext )
     1245        prefetchPieces( msgs );
     1246    } else if( fext ) {
    12321247        protocolSendReject( msgs, req );
     1248    }
    12331249}
    12341250
     
    17711787
    17721788        tr_free( blocks );
    1773     }
    1774 }
    1775 
    1776 static void
    1777 prefetchPieces( tr_peermsgs *msgs )
    1778 {
    1779     int i;
    1780 
    1781     /* Maintain 12 prefetched blocks per unchoked peer */
    1782     for( i=msgs->prefetchCount; i<msgs->peer->pendingReqsToClient && i<12; ++i )
    1783     {
    1784         const struct peer_request * req = msgs->peerAskedFor + i;
    1785         tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length );
    1786         ++msgs->prefetchCount;
    17871789    }
    17881790}
Note: See TracChangeset for help on using the changeset viewer.