]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #2551 "when uploading to peers, prefetch local data from disk" -- prefet...
authorCharles Kerr <charles@transmissionbt.com>
Sat, 5 Dec 2009 19:30:15 +0000 (19:30 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sat, 5 Dec 2009 19:30:15 +0000 (19:30 +0000)
libtransmission/peer-msgs.c

index b603c92df1b5f093d3a087352cda963f547840af..e6fd889fb88c5ce90708ba5477bff7cab20a752e 100644 (file)
@@ -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; i<msgs->peerAskedForCount; ++i )
+    /* Maintain 12 prefetched blocks per unchoked peer */
+    for( i=msgs->prefetchCount; i<msgs->peerAskedForCount && 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;
     }
 }