Skip to content

Commit a5c6e08

Browse files
committed
Merge #1492: Overhaul stats: Simplify torrent-repository package before adding events
7215f6e refactor: [#1491] clean tests in torrent-repository (Jose Celano) 1f5d18f refactor: [#1491] remove duplicate code (Jose Celano) 09bbef7 refactor: [#1491] rename varaible (Jose Celano) 32acbb1 refactor: [#1491] rename method (Jose Celano) 21b18e4 refactor: [#1491] move functionality from InMemoryTorrentRepository to TorrentRepository (Jose Celano) df00533 refactor: [#1491] rename main types in torrent-repository pkg (Jose Celano) 9be7c68 refactor: [#1491] remove redundant type aliases (Jose Celano) 71aa8d0 fix: [#1491] deadlock running tests (Jose Celano) f106c01 refactor: [#1491] move type alias to torrent-repository pkg (Jose Celano) 2b0727e refactor: [#1491] reorganize repository module (Jose Celano) 0acfc8f refactor: [#1491] remove unneeded type alias EntrySingle (Jose Celano) f868b04 refactor: [#1491] put implementation and type in the same module (Jose Celano) e87479e refactor: [#1491] extract mod torrent (Jose Celano) e0a4aac feat!: [#1491] remove unneeded generic (Jose Celano) ecd2266 feat!: [#1491] remove unused traits Entry and EntrySync (Jose Celano) 382e0af faet!: [#1491] remove unused trait Repository (Jose Celano) 89123fa feat!: [#1491] remove unused traits RepositoryAsync and EntryAsync (Jose Celano) b2a9684 feat!: [#1491] remove unused torrent repository entry types (Jose Celano) 16a6d08 feat!: [#1491] remove unused torrent repositories (Jose Celano) 3d53b23 feat: [#1491] copy torrent repo benchmarking into a new pkg (Jose Celano) Pull request description: Simplify `torrent-repository` package [before adding events](#1358). It would be overkill to maintain all the implementations. ### Subtasks - [x] Copy benchmarking code to a new workspace package `torrent-repository-benchmarking`. - [x] Remove code not used in production from the `torrent-repository` package. - [x] Unused repositories - [x] Unused entries - [x] Remove unused traits `RepositoryAsync`, `EntryAsync`, `Entry`, `EntrySync`, etc. - [x] Remove generics. - [x] Rename main types - [x] ~~Import the `bittorrent_tracker_core::torrent::repository::in_memory::InMemoryTorrentRepository` type from the `tracker-repo` package.~~ **DISCARDED**. See #1358 (comment). - [x] Clean tests ACKs for top commit: josecelano: ACK 7215f6e Tree-SHA512: a7616eae597ad15302bd30f216437bdf2bcf101e7bcc5d2391c6d23646826aed92cf393d5b79865a57ad10e827da06b6adbb830c1cd5b55eb44dcd0b985853dc
2 parents 659d174 + 7215f6e commit a5c6e08

File tree

54 files changed

+3220
-1266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3220
-1266
lines changed

.github/workflows/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ jobs:
7878
cargo publish -p torrust-tracker-metrics
7979
cargo publish -p torrust-tracker-primitives
8080
cargo publish -p torrust-tracker-test-helpers
81+
cargo publish -p torrust-tracker-torrent-benchmarking
8182
cargo publish -p torrust-tracker-torrent-repository
8283
cargo publish -p torrust-udp-tracker-server

Cargo.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ torrust-rest-tracker-api-client = { version = "3.0.0-develop", path = "packages/
6868
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "packages/test-helpers" }
6969

7070
[workspace]
71-
members = ["console/tracker-client"]
71+
members = ["console/tracker-client", "packages/torrent-repository-benchmarking"]
7272

7373
[profile.dev]
7474
debug = 1

packages/http-tracker-core/src/statistics/services.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub async fn get_metrics(
4747
in_memory_torrent_repository: Arc<InMemoryTorrentRepository>,
4848
stats_repository: Arc<Repository>,
4949
) -> TrackerMetrics {
50-
let torrents_metrics = in_memory_torrent_repository.get_torrents_metrics();
50+
let torrents_metrics = in_memory_torrent_repository.get_aggregate_swarm_metadata();
5151
let stats = stats_repository.get_stats().await;
5252

5353
TrackerMetrics {

packages/rest-tracker-api-core/src/statistics/services.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub async fn get_metrics(
3232
http_stats_repository: Arc<bittorrent_http_tracker_core::statistics::repository::Repository>,
3333
udp_server_stats_repository: Arc<udp_server_statistics::repository::Repository>,
3434
) -> TrackerMetrics {
35-
let torrents_metrics = in_memory_torrent_repository.get_torrents_metrics();
35+
let torrents_metrics = in_memory_torrent_repository.get_aggregate_swarm_metadata();
3636
let udp_banned_ips_total = ban_service.read().await.get_banned_ips_total();
3737
let http_stats = http_stats_repository.get_stats().await;
3838
let udp_server_stats = udp_server_stats_repository.get_stats().await;
@@ -97,7 +97,7 @@ pub async fn get_labeled_metrics(
9797
udp_stats_repository: Arc<bittorrent_udp_tracker_core::statistics::repository::Repository>,
9898
udp_server_stats_repository: Arc<udp_server_statistics::repository::Repository>,
9999
) -> TrackerLabeledMetrics {
100-
let _torrents_metrics = in_memory_torrent_repository.get_torrents_metrics();
100+
let _torrents_metrics = in_memory_torrent_repository.get_aggregate_swarm_metadata();
101101
let _udp_banned_ips_total = ban_service.read().await.get_banned_ips_total();
102102

103103
let http_stats = http_stats_repository.get_stats().await;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[package]
2+
description = "A library to runt benchmarking for different implementations of a repository of torrents files and their peers."
3+
keywords = ["library", "repository", "torrents"]
4+
name = "torrust-tracker-torrent-repository-benchmarking"
5+
readme = "README.md"
6+
7+
authors.workspace = true
8+
categories.workspace = true
9+
documentation.workspace = true
10+
edition.workspace = true
11+
homepage.workspace = true
12+
license.workspace = true
13+
publish.workspace = true
14+
repository.workspace = true
15+
rust-version.workspace = true
16+
version.workspace = true
17+
18+
[dependencies]
19+
aquatic_udp_protocol = "0"
20+
bittorrent-primitives = "0.1.0"
21+
crossbeam-skiplist = "0"
22+
dashmap = "6"
23+
futures = "0"
24+
parking_lot = "0"
25+
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
26+
torrust-tracker-clock = { version = "3.0.0-develop", path = "../clock" }
27+
torrust-tracker-configuration = { version = "3.0.0-develop", path = "../configuration" }
28+
torrust-tracker-primitives = { version = "3.0.0-develop", path = "../primitives" }
29+
zerocopy = "0.7"
30+
31+
[dev-dependencies]
32+
async-std = { version = "1", features = ["attributes", "tokio1"] }
33+
criterion = { version = "0", features = ["async_tokio"] }
34+
rstest = "0"
35+
36+
[[bench]]
37+
harness = false
38+
name = "repository_benchmark"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Torrust Tracker Torrent Repository Benchmarking
2+
3+
A library to runt benchmarking for different implementations of a repository of torrents files and their peers. Torrent repositories are used by the [Torrust Tracker](https://github.com/torrust/torrust-tracker).
4+
5+
## Benchmarking
6+
7+
```console
8+
cargo bench -p torrust-tracker-torrent-repository
9+
```
10+
11+
Example partial output:
12+
13+
```output
14+
Running benches/repository_benchmark.rs (target/release/deps/repository_benchmark-a9b0013c8d09c3c3)
15+
add_one_torrent/RwLockStd
16+
time: [63.057 ns 63.242 ns 63.506 ns]
17+
Found 12 outliers among 100 measurements (12.00%)
18+
2 (2.00%) low severe
19+
2 (2.00%) low mild
20+
2 (2.00%) high mild
21+
6 (6.00%) high severe
22+
add_one_torrent/RwLockStdMutexStd
23+
time: [62.505 ns 63.077 ns 63.817 ns]
24+
```
25+
26+
## Documentation
27+
28+
[Crate documentation](https://docs.rs/torrust-tracker-torrent-repository).
29+
30+
## License
31+
32+
The project is licensed under the terms of the [GNU AFFERO GENERAL PUBLIC LICENSE](./LICENSE).

packages/torrent-repository/benches/helpers/asyn.rs renamed to packages/torrent-repository-benchmarking/benches/helpers/asyn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::time::{Duration, Instant};
33

44
use bittorrent_primitives::info_hash::InfoHash;
55
use futures::stream::FuturesUnordered;
6-
use torrust_tracker_torrent_repository::repository::RepositoryAsync;
6+
use torrust_tracker_torrent_repository_benchmarking::repository::RepositoryAsync;
77

88
use super::utils::{generate_unique_info_hashes, DEFAULT_PEER};
99

packages/torrent-repository/benches/helpers/mod.rs renamed to packages/torrent-repository-benchmarking/benches/helpers/mod.rs

File renamed without changes.

packages/torrent-repository/benches/helpers/sync.rs renamed to packages/torrent-repository-benchmarking/benches/helpers/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::time::{Duration, Instant};
33

44
use bittorrent_primitives::info_hash::InfoHash;
55
use futures::stream::FuturesUnordered;
6-
use torrust_tracker_torrent_repository::repository::Repository;
6+
use torrust_tracker_torrent_repository_benchmarking::repository::Repository;
77

88
use super::utils::{generate_unique_info_hashes, DEFAULT_PEER};
99

0 commit comments

Comments
 (0)