Giter Club home page Giter Club logo

Comments (4)

kozlovsky avatar kozlovsky commented on June 18, 2024 1

After some investigation, I need to say that the previous formula all_time_upload / total_done is close to the correct answer and is an expected way to calculate the ratio.

For each torrent session, we have:

  • total_upload, total_download - the number of bytes downloaded and uploaded to all peers, accumulated, this session only. The session restarts when a torrent is paused and restarted again. When a torrent is paused, these counters are reset to 0.
  • total_payload_download, total_payload_upload - the number of bytes sent and received this session, but only the actual payload data, ignoring any protocol overhead. When a torrent is paused, these counters are reset to 0.
  • all_time_upload and all_time_download - are accumulated byte counters; they are saved in and restored from resume data to keep totals across sessions.
  • total_done - the total number of bytes of the file(s) that we have. All this does not necessarily have to be downloaded during this session.

The ratio value is commonly considered as (uploaded / downloaded), where the exact meaning of "uploaded" and "downloaded" can differ slightly depending on a specific corner case and a specific torrent client.

  • When a user pauses and restarts a torrent several times, he still expects the ratio to be calculated over all session restarts, so total_upload and total_download are unsuitable.
  • all_time_upload and all_time_download suits better, but we should not include protocol overhead and rejected blocks that failed integrity checks in the total download. Using all_time_download could potentially inflate the download portion of the ratio if some torrent pieces were downloaded multiple times due to errors or incomplete transfers. Therefore, total_done is the most suitable counter for the ratio calculation.

But I agree that the calculated ratio does not match with the up / down counters because counters currently only display the data for the current session (after the torrent was unpaused). To fix it, we should also display the total number of uploaded/downloaded bytes.

So, the torrent statistics can be displayed as:

Ratio: 0.1, up: 1 MB (total 100 MB), down: 2 MB (total 1 GB)

This should remove user confusion, as the ratio is calculated for totals that will be displayed now.

There is a corner case that is not correctly handled by the current formula: when a user seeds a pre-downloaded torrent, and the total_done counter is 0, the ratio is calculated as 0. It should be ♾ or "MAX" instead because 0 has the opposite meaning for the ratio.

from tribler.

Dmole avatar Dmole commented on June 18, 2024 1

I think it would make most sense to display just the all-time ratio/numbers but if both are to be shown then separate them like this:

Ratio: 0.1, up: 100 MB, down: 1 GB (Session Ratio: 0.5, up: 1 MB, down: 2 MB)

from tribler.

qstokkink avatar qstokkink commented on June 18, 2024

For debugging, a breakdown of these numbers:

What is shown:

up = format_size(self.current_download['total_up'])
down = format_size(self.current_download['total_down'])
self.window().download_detail_ratio_label.setText(
f"{self.current_download['ratio']:.3f}, up: {up}, down: {down}"
)

Where it comes from:

"total_up": state.get_total_transferred(UPLOAD),
"total_down": state.get_total_transferred(DOWNLOAD),
"ratio": state.get_seeding_ratio(),

How it's implemented:

def get_total_transferred(self, direct):
"""
Returns the total amount of up or downloaded bytes.
@return The amount in bytes.
"""
if not self.lt_status:
return 0
elif direct == UPLOAD:
return self.lt_status.total_upload
return self.lt_status.total_download
def get_seeding_ratio(self):
if self.lt_status and self.lt_status.total_done > 0:
return self.lt_status.all_time_upload / float(self.lt_status.total_done)
return 0

The core of the inconsistency seems to be that the shown ratio is all_time_upload / total_done and the expected ratio (based on the reported "up" and "down") is total_upload / total_download.

from tribler.

synctext avatar synctext commented on June 18, 2024

All time ratio is defined as total from, say, 10 Tribler sessions. The original if report was (possibly) simply that all counters reset when restarting Tribler.

from tribler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.