Changeset 9396


Ignore:
Timestamp:
Oct 25, 2009, 2:36:03 AM (13 years ago)
Author:
livings124
Message:

when calculating the "smoothed" eta, 1. only factor in previous speeds when those speeds were recent (ie. if we just resumed from pause, discard the previous speed) and 2. factor in if the speed was 0 as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r9387 r9396  
    889889{
    890890    tr_stat *               s;
    891     int                     usableSeeds = 0;
     891    int                     usableSeeds;
    892892    uint64_t                now;
    893893    double                  downloadedForRatio, seedRatio=0;
     
    981981    {
    982982        case TR_STATUS_DOWNLOAD:
     983            /* etaSpeed exists because if we pieceDownloadSpeed directly,
     984             * brief fluctuations cause the ETA to jump all over the place.
     985             * so, etaSpeed is a smoothed-out version of pieceDownloadSpeed
     986             * to dampen the effect of fluctuations */
     987            if( ( tor->etaSpeedCalculatedAt + 800 ) < now ) {
     988                tor->etaSpeed = ( ( tor->etaSpeedCalculatedAt + 4000 ) < now )
     989                    ? s->pieceDownloadSpeed /* if no recent previous speed, no need to smooth */
     990                    : 0.8*tor->etaSpeed + 0.2*s->pieceDownloadSpeed; /* smooth across 5 readings */
     991                tor->etaSpeedCalculatedAt = now;
     992            }
     993           
    983994            if( s->leftUntilDone > s->desiredAvailable )
    984995                s->eta = TR_ETA_NOT_AVAIL;
    985996            else if( s->pieceDownloadSpeed < 0.1 )
    986997                s->eta = TR_ETA_UNKNOWN;
    987             else {
    988                 /* etaSpeed exists because if we pieceDownloadSpeed directly,
    989                  * brief fluctuations cause the ETA to jump all over the place.
    990                  * so, etaSpeed is a smoothed-out version of pieceDownloadSpeed
    991                  * to dampen the effect of fluctuations */
    992                 if( ( tor->etaSpeedCalculatedAt + 800 ) < now ) {
    993                     tor->etaSpeedCalculatedAt = now;
    994                     tor->etaSpeed = (fabs(tor->etaSpeed)<0.0001)
    995                         ? s->pieceDownloadSpeed /* if no previous speed, no need to smooth */
    996                         : 0.8*tor->etaSpeed + 0.2*s->pieceDownloadSpeed; /* smooth across 5 readings */
    997                 }
     998            else
    998999                s->eta = s->leftUntilDone / tor->etaSpeed / 1024.0;
    999             }
    10001000            break;
    10011001
Note: See TracChangeset for help on using the changeset viewer.