]> granicus.if.org Git - transmission/commitdiff
part 1 of Aloisius' performance patch
authorCharles Kerr <charles@transmissionbt.com>
Fri, 27 Jun 2008 02:42:44 +0000 (02:42 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Fri, 27 Jun 2008 02:42:44 +0000 (02:42 +0000)
libtransmission/peer-io.c
libtransmission/peer-mgr.c
libtransmission/peer-msgs.c
libtransmission/ratecontrol.c

index 413bfa13fe69e7cfe9d21d24fc5b3e905228ff2e..75ed57c41da56dff5d5a527f62448beea6347adc 100644 (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 );
 }
 
 /**
index b2a56b7780b4bfa7cf6ea5da0563f593f617a7fe..beeebe7395ea0cb568977e7b5e4ec89500579fc2 100644 (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
index b143664af3ff1f4a35211c7f53233c6da00dbe18..f2b83bd76818a2fd6860c77b2d5f35f498a8c3c2 100644 (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) );
index 84aa1034bfccf700fba4175ab2a7f2c72f721384..cdf6c6e2cd8e2a3d38ba9655eb2aae71b1a33203 100644 (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;