(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...
This commit is contained in:
parent
7da3b81cda
commit
24129b9bf5
|
@ -1204,6 +1204,20 @@ updatePeerProgress( tr_peermsgs * msgs )
|
|||
firePeerProgress( msgs );
|
||||
}
|
||||
|
||||
static void
|
||||
prefetchPieces( tr_peermsgs *msgs )
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Maintain 12 prefetched blocks per unchoked peer */
|
||||
for( i=msgs->prefetchCount; i<msgs->peer->pendingReqsToClient && i<12; ++i )
|
||||
{
|
||||
const struct peer_request * req = msgs->peerAskedFor + i;
|
||||
tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length );
|
||||
++msgs->prefetchCount;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
peerMadeRequest( tr_peermsgs * msgs,
|
||||
const struct peer_request * req )
|
||||
|
@ -1226,10 +1240,12 @@ peerMadeRequest( tr_peermsgs * msgs,
|
|||
else
|
||||
allow = TRUE;
|
||||
|
||||
if( allow )
|
||||
if( allow ) {
|
||||
msgs->peerAskedFor[msgs->peer->pendingReqsToClient++] = *req;
|
||||
else if( fext )
|
||||
prefetchPieces( msgs );
|
||||
} else if( fext ) {
|
||||
protocolSendReject( msgs, req );
|
||||
}
|
||||
}
|
||||
|
||||
static tr_bool
|
||||
|
@ -1773,20 +1789,6 @@ updateBlockRequests( tr_peermsgs * msgs )
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
prefetchPieces( tr_peermsgs *msgs )
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Maintain 12 prefetched blocks per unchoked peer */
|
||||
for( i=msgs->prefetchCount; i<msgs->peer->pendingReqsToClient && i<12; ++i )
|
||||
{
|
||||
const struct peer_request * req = msgs->peerAskedFor + i;
|
||||
tr_ioPrefetch( msgs->torrent, req->index, req->offset, req->length );
|
||||
++msgs->prefetchCount;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t
|
||||
fillOutputBuffer( tr_peermsgs * msgs, time_t now )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue