1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 00:04:06 +00:00

part 1 of Aloisius' performance patch

This commit is contained in:
Charles Kerr 2008-06-27 02:42:44 +00:00
parent ed295c2b5d
commit fd06d85aee
4 changed files with 15 additions and 6 deletions

View file

@ -316,6 +316,7 @@ tr_peerIoSetTimeoutSecs( tr_peerIo * io, int secs )
{
io->timeout = secs;
bufferevent_settimeout( io->bufev, io->timeout, io->timeout );
bufferevent_enable( io->bufev, EV_READ|EV_WRITE );
}
/**

View file

@ -60,7 +60,7 @@ enum
RECONNECT_PERIOD_MSEC = (2 * 1000),
/* max # of peers to ask fer per torrent per reconnect pulse */
MAX_RECONNECTIONS_PER_PULSE = 1,
MAX_RECONNECTIONS_PER_PULSE = 4,
/* max number of peers to ask for per second overall.
* this throttle is to avoid overloading the router */
@ -1537,7 +1537,16 @@ compareChoke( const void * va, const void * vb )
{
const struct ChokeData * a = va;
const struct ChokeData * b = vb;
return -tr_compareUint32( a->rate, b->rate );
int diff = 0;
if( diff == 0 ) /* prefer higher dl speeds */
diff = -tr_compareDouble( a->peer->rateToClient, b->peer->rateToClient );
if( diff == 0 ) /* prefer higher ul speeds */
diff = -tr_compareDouble( a->peer->rateToPeer, b->peer->rateToPeer );
if( diff == 0 ) /* prefer unchoked */
diff = (int)a->peer->peerIsChoked - (int)b->peer->peerIsChoked;
return diff;
}
static int

View file

@ -1325,7 +1325,6 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen )
case BT_INTERESTED:
dbgmsg( msgs, "got Interested" );
msgs->info->peerIsInterested = 1;
tr_peerMsgsSetChoke( msgs, 0 );
break;
case BT_NOT_INTERESTED:
@ -1734,7 +1733,7 @@ static void
gotError( struct bufferevent * evbuf UNUSED, short what, void * vmsgs )
{
if( what & EVBUFFER_TIMEOUT )
dbgmsg( vmsgs, "libevent got a timeout, what=%hd", what );
dbgmsg( vmsgs, "libevent got a timeout, what=%hd, secs=%d", what, evbuf->timeout_read );
if( what & ( EVBUFFER_EOF | EVBUFFER_ERROR ) )
dbgmsg( vmsgs, "libevent got an error! what=%hd, errno=%d (%s)",
what, errno, tr_strerror(errno) );

View file

@ -30,7 +30,7 @@
#include "utils.h"
#define GRANULARITY_MSEC 500
#define SHORT_INTERVAL_MSEC 4000
#define SHORT_INTERVAL_MSEC 1000
#define LONG_INTERVAL_MSEC 8000
#define HISTORY_SIZE (LONG_INTERVAL_MSEC / GRANULARITY_MSEC)
@ -56,7 +56,7 @@ rateForInterval( const tr_ratecontrol * r, int interval_msec )
int i = r->newest;
for( ;; )
{
if( r->transfers[i].date < cutoff )
if( r->transfers[i].date <= cutoff )
break;
bytes += r->transfers[i].size;