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;