Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Popularity metric #20180

Merged
merged 1 commit into from
Apr 1, 2024
Merged

Conversation

Jamim
Copy link
Contributor

@Jamim Jamim commented Dec 25, 2023

Hello,

Thank you for this amazing torrent client! πŸ™‡πŸ»β€β™‚οΈ

I believe it would be nice to have a metric that shows how popular a torrent is.
It's especially helpful for clean up purposes if you want to delete the least popular torrents.
So I'd like to suggest an implementation of the Popularity metric.

Popularity

A new metric is inspired by the Interest Rate from the finance world.
An implementation is adapted to the use-case and has nothing to do with money.

Popularity is an average number that represents how many times a torrent is seeded back on a monthly basis calculated as all_time_upload / all_time_download / (activeTime() / MONTHS_SECONDS), translated to realRatio() / activeMonths for simplicity. The resulting values are reasonably small and easy to comprehend, just as for the classic Ratio metric.

Metric's name might be different, but I've kept it due to lack of creativity πŸ€·πŸ»β€β™‚οΈ
Thanks to @Mazino-Urek and @LordNyriox for suggesting a better name!

Screenshots

Native UI

Native UI

Web UI

Web UI

Best regards!

@glassez
Copy link
Member

glassez commented Dec 25, 2023

@Jamim
Is this some kind of commonly used (well-known) metric?
Anyway would you mind to provide more details about it in the OP?

@@ -129,6 +129,7 @@ namespace BitTorrent
static const qreal MAX_RATIO;
static const int MAX_SEEDING_TIME;
static const int MAX_INACTIVE_SEEDING_TIME;
static const qreal INTEREST_RATE_PERIOD;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that it should be declared public. Just move its declaration in "torrentimpl.cpp".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! INTEREST_RATE_PERIOD has been renamed to MONTH_SECONDS and moved to torrentimpl.cpp.

qreal TorrentImpl::interestRate() const
{
qlonglong elapsed = activeTime();
return elapsed ? realRatio() / (elapsed / INTEREST_RATE_PERIOD) : 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discourage to use numbers as booleans.

Copy link
Contributor

@thalieht thalieht Dec 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't elapsed ever be zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discourage to use numbers as booleans.

A comparison to zero has been added.

Can't elapsed ever be zero?

Yes, it's zero in case a torrent is added but not yet started due to the Start torrent checkbox was toggled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't elapsed ever be zero?

Oops, i was asking for division by zero but didn't pay attention to the left side.

@Jamim
Copy link
Contributor Author

Jamim commented Dec 25, 2023

Hello @glassez and @thalieht,

Thank you for reviewing this PR so quickly! πŸš€

I've added some information about the metric to the original post and made necessary changes to the code. Could you please take a look once again?

Thanks in advance!

@thalieht
Copy link
Contributor

It's especially helpful for clean up purposes if you want to delete the least popular torrents.

all_time_upload / all_time_download / (activeTime() / MONTHS_SECONDS)

100 GB / 10 GB / 2 months = 5
100 GB / 100 GB / 2 months = 0.5

You don't like big torrents huh :)

@Jamim
Copy link
Contributor Author

Jamim commented Dec 25, 2023

100 GB / 10 GB / 2 months = 5
100 GB / 100 GB / 2 months = 0.5

You don't like big torrents huh :)

Being as helpful for the community while using only 1/10 of the volume is an appealing option πŸ˜…

@Mazino-Urek
Copy link
Contributor

Well, I am from Finance World and find this analogy to be a bit hilarious.

Probably a better naming would be just "interest" or "Popularity". Nice idea, though.

@Jamim Jamim changed the title Add the Interest Rate metric Add the Popularity metric Dec 26, 2023
@Jamim
Copy link
Contributor Author

Jamim commented Dec 26, 2023

Thank you @Mazino-Urek and @LordNyriox for suggesting a better name! πŸ™‡πŸ»β€β™‚οΈ
I've made necessary changes to rename the suggested metric to Popularity.

@glassez
Copy link
Member

glassez commented Dec 27, 2023

Maybe I just don't understand something, or it's because I'm not familiar with its use, but will Popularity have the expected value if, for example, a torrent reached a large ratio (say 10.0) in the first month after it was added, and then it had it (almost) unchanged for several months?

@thalieht
Copy link
Contributor

IMO "popularity" would be (finished or active time / time spent actually seeding) or something of the sort and maybe put the month somewhere in there.
Even then it could be skewed by other things e.g. not enough upload slots i.e. all currently available upload slots are occupied by other torrents.

@Jamim
Copy link
Contributor Author

Jamim commented Dec 28, 2023

Hello @glassez,

will Popularity have the expected value if, for example, a torrent reached a large ratio (say 10.0) in the first month after it was added, and then it had it (almost) unchanged for several months?

Based on your input, I've prepared a script that draws a plot which shows a correlation between Ratio and Popularity metrics over time.
Popularity will slowly decay with deceleration after first 25 days πŸ“‰
plot
You can play with the ratio curve to see how it affects Popularity.

Regarding expectations, the values look fine to me βœ…

@Jamim
Copy link
Contributor Author

Jamim commented Dec 28, 2023

Hello @thalieht,

IMO "popularity" would be (finished or active time / time spent actually seeding) or something of the sort and maybe put the month somewhere in there.

By actually seeding, do you mean time while data was actively uploaded after completion of downloading, excluding idle? If so, I'm not sure how to receive such information.

Even then it could be skewed by other things e.g. not enough upload slots i.e. all currently available upload slots are occupied by other torrents.

That's true. I understand there's no perfect formula for the popularity, but at least it's a good starting point and the initial formula might be changed based on user feedback in the future.

@thalieht
Copy link
Contributor

By actually seeding, do you mean time while data was actively uploaded after completion of downloading, excluding idle?

Yep.

If so, I'm not sure how to receive such information.

Wow. I was sure libtorrent would have such a counter but i can't find anything. Let's forget about it then.

@Jamim
Copy link
Contributor Author

Jamim commented Dec 28, 2023

In order to gather some additional feedback, I've submitted a post to Reddit:

src/base/bittorrent/torrentimpl.cpp Outdated Show resolved Hide resolved
src/base/bittorrent/torrentimpl.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Chocobo1 Chocobo1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the last comment, other code looks fine.
ps. I didn't consider the usefulness of this metric, I'll leave it for others to decide.

@@ -171,6 +171,7 @@ QVariant TransferListModel::headerData(const int section, const Qt::Orientation
case TR_DLSPEED: return tr("Down Speed", "i.e: Download speed");
case TR_UPSPEED: return tr("Up Speed", "i.e: Upload speed");
case TR_RATIO: return tr("Ratio", "Share ratio");
case TR_POPULARITY: return tr("Popularity", "Ratio / Time Active (in months), indicates how popular the torrent is");
Copy link
Member

@Chocobo1 Chocobo1 Dec 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case TR_POPULARITY: return tr("Popularity", "Ratio / Time Active (in months), indicates how popular the torrent is");
case TR_POPULARITY: return tr("Popularity");

The second parameter is for translation disambiguation so you don't need it.

However I think you should move the explanation of the metric to a tooltip (preferably in both GUI and WebUI). The tooltip can be set on the label.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've applied your suggestion. Now I'm working on adding tooltips.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added tooltips where it was possible without making a lot of additional changes.
It's not trivial to do so for the WebUI in most cases. It would be better to submit an additional PR to avoid unnecessary discussions on this one.

Native UI

Native UI

Web UI

@Jamim Jamim marked this pull request as draft January 3, 2024 06:37
Copy link

github-actions bot commented Mar 4, 2024

This PR is stale because it has been 60 days with no activity. This PR will be automatically closed within 7 days if there is no further activity.

@Jamim Jamim marked this pull request as ready for review March 7, 2024 17:50
@Jamim Jamim requested a review from Chocobo1 March 7, 2024 17:50
@github-actions github-actions bot removed the Stale label Mar 8, 2024
@Jamim
Copy link
Contributor Author

Jamim commented Mar 11, 2024

Hello @glassez, @thalieht, and @Chocobo1!

Would you mind reviewing the current version of changes?

Thanks in advance!

Chocobo1
Chocobo1 previously approved these changes Mar 12, 2024
I believe it would be nice to have a metric
that shows how popular a torrent is.
It's especially helpful for clean up purposes
if you want to delete the least popular torrents.

Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
@glassez glassez added the Core label Mar 12, 2024
@glassez glassez added this to the 5.0 milestone Mar 12, 2024
@glassez glassez merged commit f37d0c4 into qbittorrent:master Apr 1, 2024
13 checks passed
@glassez
Copy link
Member

glassez commented Apr 1, 2024

@Jamim
Thank you!

@Jamim Jamim deleted the feature/interest-rate branch April 2, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants