Opened 14 years ago

Closed 14 years ago

#665 closed Bug (fixed)

Ratio calculations aren't strictly accurate when re-seeding a torrent

Reported by: maurj Owned by: charles
Priority: Low Milestone: 1.03
Component: libtransmission Version: 1.02
Severity: Normal Keywords:


Recently, I've been re-seeding an old torrent, and when doing so Transmission did the usual job of checking the existing files. Turned out I had missed some files previously, so I had to download a chunk of data to complete the torrent.

Now I have the full set of data, and am uploading, Transmission is tracking the ratio for the torrent based on the total size of the torrent, rather than based on the amount I have actually downloaded.

It's a 7.02GB torrent, of which I downloaded 400MB when I re-seeded it, and I've seeded 1.63GB these past few days. It is reporting a ratio of 0.23, when it should really be 4.08 or something similar.

Change History (3)

comment:1 Changed 14 years ago by charles

  • Component changed from Transmission to libtransmission
  • Owner set to charles

comment:2 Changed 14 years ago by charles

Currently the ratio is calculated like this:

    s->ratio = tr_getRatio( s->uploadedEver,
                            MAX( s->downloadedEver, s->haveValid ) );

tr_getRatio() is a trivial function that takes a numerator and denominator, checks against division by zero, and returns TR_RATIO_INF, TR_RATIO_NA, or the ratio.

(1) in the general case, we should use downloadedEver as the denominator. This works for the the most common case of downloading a torrent that you didn't already have. It also catches cases like the user deleting and re-downloading a file, which will correctly cause the ratio to drop.

(2) if the user is the original seeder, downloadedEver will be zero. This would give an infinite ratio, which isn't very informative, so in that case it's better to use the torrent size. (ticket #15)

(3) in the case described in this report, we should use downloadedEver in the denominator, even though it's less than the torrent size.

The `MAX' is breaking case (3) here. It was introduced in r1769, and from reading the diffs, I think it was to simplify the code. I think we can safely replace it with this, which IMO is pretty straightforward:

    if( s->downloadedEver )
        s->ratio = tr_getRatio( s->uploadedEver, s->downloadedEver );
        s->ratio = tr_getRatio( s->uploadedEver, s->haveValid );

comment:3 Changed 14 years ago by charles

  • Milestone changed from None Set to 1.03
  • Resolution set to fixed
  • Status changed from new to closed

1.0x: r4859 trunk: r4860

Note: See TracTickets for help on using tickets.