Skip to content

Commit 20b052d

Browse files
committed
Merge #522: feat: added benchmarking binary for torrent repository struct
ebb7d4c chore: make Containerfile use nightly rust (Warm Beer) 1735a7a chore: only run contract, deployment & testing jobs in nightly rust (Warm Beer) 6087e4f feat: added benchmarking binary for torrent repository (Warm Beer) Pull request description: Moved the `Tracker.torrents` field to be its own `TorrentRepository` struct with different implementations. Added a new crate that benchmarks the different `TorrentRepository` implementations for speed. ### Run benchmarks ```shell cargo run --release -p torrust-torrent-repository-benchmarks -- --threads 4 --sleep 0 --compare true ``` #### Example result ```shell tokio::sync::RwLock<std::collections::BTreeMap<InfoHash, Entry>> add_one_torrent: Avg/AdjAvg: (146ns, 0ns) update_one_torrent_in_parallel: Avg/AdjAvg: (5.965616ms, 5.816375ms) add_multiple_torrents_in_parallel: Avg/AdjAvg: (14.050554ms, 14.132902ms) update_multiple_torrents_in_parallel: Avg/AdjAvg: (7.201337ms, 7.120315ms) std::sync::RwLock<std::collections::BTreeMap<InfoHash, Entry>> add_one_torrent: Avg/AdjAvg: (82ns, 83ns) update_one_torrent_in_parallel: Avg/AdjAvg: (27.311075ms, 26.869114ms) add_multiple_torrents_in_parallel: Avg/AdjAvg: (28.967141ms, 28.967141ms) update_multiple_torrents_in_parallel: Avg/AdjAvg: (48.316966ms, 0ns) std::sync::RwLock<std::collections::BTreeMap<InfoHash, Arc<std::sync::Mutex<Entry>>>> add_one_torrent: Avg/AdjAvg: (137ns, 125ns) update_one_torrent_in_parallel: Avg/AdjAvg: (5.057729ms, 5.057729ms) add_multiple_torrents_in_parallel: Avg/AdjAvg: (48.833962ms, 48.833962ms) update_multiple_torrents_in_parallel: Avg/AdjAvg: (6.193212ms, 6.071166ms) tokio::sync::RwLock<std::collections::BTreeMap<InfoHash, Arc<std::sync::Mutex<Entry>>>> add_one_torrent: Avg/AdjAvg: (174ns, 166ns) update_one_torrent_in_parallel: Avg/AdjAvg: (5.56332ms, 5.56332ms) add_multiple_torrents_in_parallel: Avg/AdjAvg: (16.360504ms, 15.872786ms) update_multiple_torrents_in_parallel: Avg/AdjAvg: (6.800225ms, 6.890521ms) tokio::sync::RwLock<std::collections::BTreeMap<InfoHash, Arc<tokio::sync::Mutex<Entry>>>> add_one_torrent: Avg/AdjAvg: (192ns, 208ns) update_one_torrent_in_parallel: Avg/AdjAvg: (6.374304ms, 6.17711ms) add_multiple_torrents_in_parallel: Avg/AdjAvg: (17.313591ms, 17.089898ms) update_multiple_torrents_in_parallel: Avg/AdjAvg: (6.955371ms, 6.975057ms) ``` ### Relevant issues #496 #495 Top commit has no ACKs. Tree-SHA512: 062d18c91b1d89ab95eda5ddc2cb7674d481b705a21c43e9cf3a11e0bf71e52bb6bccd5b5e4404fcf8ebdc442764dd60006c6962aac2a414c4b4cdecfa422a67
2 parents a3274dc + ebb7d4c commit 20b052d

File tree

19 files changed

+1117
-128
lines changed

19 files changed

+1117
-128
lines changed

.github/workflows/contract.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
toolchain: [stable, nightly]
17+
toolchain: [nightly]
1818

1919
steps:
2020
- id: checkout

.github/workflows/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
toolchain: [stable, nightly]
15+
toolchain: [nightly]
1616

1717
steps:
1818
- id: checkout
@@ -44,7 +44,7 @@ jobs:
4444
name: Setup Toolchain
4545
uses: dtolnay/rust-toolchain@stable
4646
with:
47-
toolchain: stable
47+
toolchain: ${{ matrix.toolchain }}
4848

4949
- id: publish
5050
name: Publish Crates

.github/workflows/testing.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
strategy:
4141
matrix:
42-
toolchain: [stable, nightly]
42+
toolchain: [nightly]
4343

4444
steps:
4545
- id: checkout
@@ -79,7 +79,7 @@ jobs:
7979

8080
strategy:
8181
matrix:
82-
toolchain: [stable, nightly]
82+
toolchain: [nightly]
8383

8484
steps:
8585
- id: checkout

Cargo.lock

Lines changed: 97 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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ version = "3.0.0-alpha.12-develop"
3232
[dependencies]
3333
aquatic_udp_protocol = "0"
3434
async-trait = "0"
35-
axum = "0.6"
35+
axum = { version = "0.6", features = ["macros"] }
3636
axum-client-ip = "0.4"
3737
axum-server = { version = "0", features = ["tls-rustls"] }
3838
binascii = "0"
@@ -68,16 +68,18 @@ tower-http = { version = "0.4", features = ["compression-full"] }
6868
uuid = { version = "1", features = ["v4"] }
6969

7070
[dev-dependencies]
71+
criterion = { version = "0.5.1", features = ["async_tokio"] }
7172
local-ip-address = "0"
7273
mockall = "0"
74+
once_cell = "1.18.0"
7375
reqwest = { version = "0", features = ["json"] }
7476
serde_bytes = "0"
7577
serde_repr = "0"
7678
serde_urlencoded = "0"
7779
torrust-tracker-test-helpers = { version = "3.0.0-alpha.12-develop", path = "packages/test-helpers" }
7880

7981
[workspace]
80-
members = ["contrib/bencode", "packages/configuration", "packages/located-error", "packages/primitives", "packages/test-helpers"]
82+
members = ["contrib/bencode", "packages/configuration", "packages/located-error", "packages/primitives", "packages/test-helpers", "packages/torrent-repository-benchmarks"]
8183

8284
[profile.dev]
8385
debug = 1

Containerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
# Torrust Tracker
44

55
## Builder Image
6-
FROM rust:bookworm as chef
6+
FROM rustlang/rust:nightly-bookworm as chef
77
WORKDIR /tmp
88
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
99
RUN cargo binstall --no-confirm cargo-chef cargo-nextest
1010

1111
## Tester Image
12-
FROM rust:slim-bookworm as tester
12+
FROM rustlang/rust:nightly-bookworm-slim as tester
1313
WORKDIR /tmp
1414

1515
RUN apt-get update; apt-get install -y curl sqlite3; apt-get autoclean
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "torrust-torrent-repository-benchmarks"
3+
authors.workspace = true
4+
categories.workspace = true
5+
description.workspace = true
6+
documentation.workspace = true
7+
edition.workspace = true
8+
homepage.workspace = true
9+
keywords.workspace = true
10+
license.workspace = true
11+
publish.workspace = true
12+
repository.workspace = true
13+
rust-version.workspace = true
14+
version.workspace = true
15+
16+
[dependencies]
17+
aquatic_udp_protocol = "0.8.0"
18+
clap = { version = "4.4.8", features = ["derive"] }
19+
futures = "0.3.29"
20+
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
21+
torrust-tracker = { path = "../../" }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use clap::Parser;
2+
3+
#[derive(Parser, Debug)]
4+
#[command(author, version, about, long_about = None)]
5+
pub struct Args {
6+
/// Amount of benchmark worker threads
7+
#[arg(short, long)]
8+
pub threads: usize,
9+
/// Amount of time in ns a thread will sleep to simulate a client response after handling a task
10+
#[arg(short, long)]
11+
pub sleep: Option<u64>,
12+
/// Compare with old implementations of the torrent repository
13+
#[arg(short, long)]
14+
pub compare: Option<bool>,
15+
}

0 commit comments

Comments
 (0)