Changeset 10510


Ignore:
Timestamp:
Apr 22, 2010, 3:12:31 AM (9 years ago)
Author:
charles
Message:

(trunk libT) #2993 '"Downloaded" much greater than "Have" or "verified"' -- tweak the download throttle algorithm a bit to try & address the slowness reported by Rolcol @ http://trac.transmissionbt.com/ticket/2993#comment:42

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r10500 r10510  
    194194     * Based on how many of requests are cancelled and how many are completed.
    195195     * Lower values indicate less congestion. */
    196     double                     downloadCongestion;
     196    double                     cancelRate;
    197197}
    198198Torrent;
     
    24022402         * We're working on 2. here, so we need to ignore unresponsive
    24032403         * peers in our calculations lest they confuse Transmission into
    2404          * think it's hit its bandwidth cap.
     2404         * thinking it's hit its bandwidth cap.
    24052405         */
    24062406        for( i=0; i<peerCount; ++i )
     
    24312431        else
    24322432        {
    2433             const double c = ( cancels * 30.0 ) / blocks;
    2434                  if( c > 5  ) maxPeers = t->interestedCount * 0.7;
    2435             else if( c > 3  ) maxPeers = t->interestedCount * 0.8;
    2436             else if( c > 1  ) maxPeers = t->interestedCount * 0.9;
    2437             else if( c > 0.5 ) maxPeers = t->interestedCount;
    2438             else               maxPeers = t->interestedCount + 1;
     2433            const double cancelRate = cancels / (double)(cancels + blocks);
     2434                 if( cancelRate >= 0.20 ) maxPeers = t->interestedCount * 0.7;
     2435            else if( cancelRate >= 0.10 ) maxPeers = t->interestedCount * 0.8;
     2436            else if( cancelRate >= 0.05 ) maxPeers = t->interestedCount * 0.9;
     2437            else if( cancelRate >= 0.01 ) maxPeers = t->interestedCount;
     2438            else                          maxPeers = t->interestedCount + 1;
    24392439
    24402440            /* if things are getting worse, don't add more peers */
    2441             if( ( t->downloadCongestion > 0.1 ) && ( c > t->downloadCongestion ) )
     2441            if( ( t->cancelRate > 0.01 ) && ( cancelRate > t->cancelRate ) )
    24422442                maxPeers = MIN( maxPeers, t->interestedCount );
    24432443
    2444             t->downloadCongestion = c;
    2445 /*fprintf( stderr, "OVERALL TORRENT DOWNLOAD CONGESTION: %.3f... num allowed goes from %d to %d\n", c, t->interestedCount, maxPeers );*/
     2444            t->cancelRate = cancelRate;
     2445
     2446            tordbg( t, "cancel rate is %.3f -- changing the "
     2447                       "number of peers we're interested in from %d to %d",
     2448                       cancelRate, t->interestedCount, maxPeers );
    24462449        }
    24472450    }
    24482451
    24492452    /* don't let the previous paragraph's number tweaking go too far... */
    2450     maxPeers = MAX( maxPeers, MIN_INTERESTING_PEERS );
    2451     maxPeers = MIN( maxPeers, t->tor->maxConnectedPeers );
     2453    if( maxPeers < MIN_INTERESTING_PEERS )
     2454        maxPeers = MIN_INTERESTING_PEERS;
     2455    if( maxPeers > t->tor->maxConnectedPeers )
     2456        maxPeers = t->tor->maxConnectedPeers;
    24522457
    24532458    /* separate the peers into "good" (ones with a low cancel-to-block ratio),
     
    24732478            else if( !blocks )
    24742479                bad[badCount++] = peer;
    2475             else if( ( ( cancels * 10.0 ) / blocks ) < 1.0 )
     2480            else if( ( cancels * 10 ) < blocks )
    24762481                good[goodCount++] = peer;
    24772482            else
     
    34273432        assert( tr_peerIoGetTorrentHash( io ) );
    34283433
    3429         tr_peerIoUnref( io ); /* balanced by the implicit ref in tr_peerIoNewOutgoing() */
     3434        tr_peerIoUnref( io ); /* balanced by the initial ref
     3435                                 in tr_peerIoNewOutgoing() */
    34303436
    34313437        tr_ptrArrayInsertSorted( &t->outgoingHandshakes, handshake,
Note: See TracChangeset for help on using the changeset viewer.