Skip to content

Disable torrent stats importation at start - #1511

Merged
josecelano merged 1 commit into
torrust:developfrom
josecelano:1510-disable-stats-importation-when-the-trackers-starts
May 9, 2025
Merged

josecelano merged 1 commit into
torrust:developfrom
josecelano:1510-disable-stats-importation-when-the-trackers-starts

Conversation

@josecelano

Copy link
Copy Markdown
Member

When the tracker starts, if stats persistence is enabled, all torrents that have ever been downloaded are loaded into memory (Swarms type) with their download counter.

That's the current way to count all downloads and expose that metric.

However, it does not work with millions of torrents (like in the tracker demo) becuase:

  • It's too slow.
  • It consumes too much memory (all torrents that have ever been downloaded have to be loaded).

A new solution is needed to keep that metric, but in the meantime, this disables that feature, producing these effects:

  • Non-accurate value for downloads when the tracker is restarted.
  • Increasing indefinitely the number of torrents in memory even if the "remove peerless torrents" policy is enabled (becuase this feature overrides that policy and peerless torrents are kept in memory).

@josecelano
josecelano requested a review from da2ce7 May 9, 2025 07:42
@josecelano josecelano self-assigned this May 9, 2025
@josecelano josecelano added the Bug Incorrect Behavior label May 9, 2025
When the tracker starts, if stats persistence is enabled, all torrents that have ever been downloaded are loaded into memory (`Swarms` type) with their download counter.

That's the current way to count all downloads and expose that metric.

However, it does not work with **millions of torrents** (like in the tracker demo) becuase:

- It's too slow.
- It consumes too much memory (all torrents that have ever been downloaded have to be loaded).

A new solution is needed to keep that metric, but in the meantime, this disables that feature, producing these effects:

- Non-accurate value for downloads when the tracker is restarted.
- Increasing indefinitely the number of torrents in memory even if the "remove peerless torrents" policy is enabled (becuase this feature overrides that policy and peerless torrents are kept in memory).
@josecelano
josecelano force-pushed the 1510-disable-stats-importation-when-the-trackers-starts branch from 52c27bd to cb487f3 Compare May 9, 2025 07:43
@josecelano josecelano linked an issue May 9, 2025 that may be closed by this pull request
@josecelano

Copy link
Copy Markdown
Member Author

ACK cb487f3

@codecov

codecov Bot commented May 9, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.86%. Comparing base (672dfaa) to head (cb487f3).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1511      +/-   ##
===========================================
+ Coverage    83.85%   83.86%   +0.01%     
===========================================
  Files          257      257              
  Lines        17946    17945       -1     
  Branches     17946    17945       -1     
===========================================
+ Hits         15049    15050       +1     
  Misses        2620     2620              
+ Partials       277      275       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@da2ce7

da2ce7 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Post-merge note: this pull request requested a review from this account and was closed without one at its final head. A post-merge review will not be done: The code it disabled was removed in #1542, which reworked how download counts are persisted; none of its 7 added lines remain on the default branch.

This branch was previously deployed

1 inactive deployment
coverage — cb487f36 Deployed May 9, 2025 by josecelano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect Behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable stats importation when the trackers starts

2 participants