Skip to content

Commit b0bf307

Browse files
committed
Merge #1511: Disable torrent stats importation at start
cb487f3 fix: [#1510] disable torrent stats importation at start (Jose Celano) Pull request description: 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). ACKs for top commit: josecelano: ACK cb487f3 Tree-SHA512: 476f7fe0c1633413e4fe40458d2ebd40617471f847b9268ce902988394c422fe2c155a86071f65cb8d86d82dfbbbab68d00c54f704759f3e4a51cac57a3e9ca5
2 parents 672dfaa + cb487f3 commit b0bf307

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/app.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ pub async fn start(config: &Configuration, app_container: &Arc<AppContainer>) ->
6161
async fn load_data_from_database(config: &Configuration, app_container: &Arc<AppContainer>) {
6262
load_peer_keys(config, app_container).await;
6363
load_whitelisted_torrents(config, app_container).await;
64-
load_torrents_from_database(config, app_container);
64+
// todo: disabled because of performance issues.
65+
// The tracker demo has a lot of torrents and loading them all at once is not
66+
// efficient. We also load them on demand but the total number of downloads
67+
// metric is not accurate because not all torrents are loaded.
68+
// See: https://github.com/torrust/torrust-tracker/issues/1510
69+
//load_torrents_from_database(config, app_container);
6570
}
6671

6772
async fn start_jobs(config: &Configuration, app_container: &Arc<AppContainer>) -> JobManager {
@@ -110,6 +115,7 @@ async fn load_whitelisted_torrents(config: &Configuration, app_container: &Arc<A
110115
}
111116
}
112117

118+
#[allow(dead_code)]
113119
fn load_torrents_from_database(config: &Configuration, app_container: &Arc<AppContainer>) {
114120
if config.core.tracker_policy.persistent_torrent_completed_stat {
115121
app_container

0 commit comments

Comments
 (0)