From: Charles Kerr Date: Sat, 5 Dec 2009 19:30:15 +0000 (+0000) Subject: (trunk libT) #2551 "when uploading to peers, prefetch local data from disk" -- prefet... X-Git-Tag: 1.80b5~230 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d37022211352b9557a0857a2cc8fc1b95540a699;p=transmission (trunk libT) #2551 "when uploading to peers, prefetch local data from disk" -- prefetching performance tweak described in http://trac.transmissionbt.com/ticket/2551#comment:22 -- instead of prefetching [8..12] blocks, always prefetch 12 blocks --- diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index b603c92df..e6fd889fb 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -1802,24 +1802,13 @@ static void prefetchPieces( tr_peermsgs *msgs ) { int i; - uint64_t next = 0; - /* Maintain at least 8 prefetched blocks per unchoked peer, but allow - up to 4 extra blocks if that would cause sequential writes. */ - for( i=msgs->prefetchCount; ipeerAskedForCount; ++i ) + /* Maintain 12 prefetched blocks per unchoked peer */ + for( i=msgs->prefetchCount; ipeerAskedForCount && i<12; ++i ) { const struct peer_request * req = msgs->peerAskedFor + i; - const uint64_t begin = tr_pieceOffset( msgs->torrent, req->index, req->offset, 0 ); - const uint64_t end = begin + req->length; - const tr_bool isSequential = next == begin; - - if( ( i >= 12 ) || ( !isSequential && ( i >= 8 ) ) ) - break; - tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length ); ++msgs->prefetchCount; - - next = end; } }