Skip to content

Commit

Permalink
bencher: add new tracker, torrust-tracker
Browse files Browse the repository at this point in the history
Adds a new tracker to the bencher.

https://github.com/torrust/torrust-tracker
  • Loading branch information
josecelano committed Mar 15, 2024
1 parent 69ead98 commit dd1a5f9
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/bencher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Requires Linux 6.0 or later.

- [aquatic_udp](https://github.com/greatest-ape/aquatic/)
- [opentracker](https://erdgeist.org/arts/software/opentracker/)
- [chihaya](https://github.com/chihaya/chihaya)
- [chihaya](https://github.com/chihaya/chihaya)
- [torrust-tracker](https://github.com/torrust/torrust-tracker)
2 changes: 1 addition & 1 deletion crates/bencher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct Args {

#[derive(Subcommand)]
enum Command {
/// Benchmark UDP BitTorrent trackers aquatic_udp, opentracker and chihaya
/// Benchmark UDP BitTorrent trackers aquatic_udp, opentracker, chihaya and torrust-tracker
#[cfg(feature = "udp")]
Udp(protocols::udp::UdpCommand),
}
Expand Down
107 changes: 107 additions & 0 deletions crates/bencher/src/protocols/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum UdpTracker {
AquaticIoUring,
OpenTracker,
Chihaya,
TorrustTracker,
}

impl Tracker for UdpTracker {
Expand All @@ -32,6 +33,7 @@ impl Tracker for UdpTracker {
Self::AquaticIoUring => "aquatic_udp (io_uring)".into(),
Self::OpenTracker => "opentracker".into(),
Self::Chihaya => "chihaya".into(),
Self::TorrustTracker => "torrust-tracker".into(),
}
}
}
Expand All @@ -50,6 +52,9 @@ pub struct UdpCommand {
/// Path to chihaya binary
#[arg(long, default_value = "chihaya")]
chihaya: PathBuf,
/// Path to torrust-tracker binary
#[arg(long, default_value = "torrust-tracker")]
torrust_tracker: PathBuf,
}

impl UdpCommand {
Expand All @@ -71,6 +76,9 @@ impl UdpCommand {
UdpTracker::Chihaya => vec![
ChihayaUdpRunner::new(),
],
UdpTracker::TorrustTracker => vec![
TorrustTrackerUdpRunner::new(),
],
},
load_test_runs: simple_load_test_runs(cpu_mode, &[
(8, Priority::Medium),
Expand All @@ -91,6 +99,9 @@ impl UdpCommand {
UdpTracker::Chihaya => vec![
ChihayaUdpRunner::new(),
],
UdpTracker::TorrustTracker => vec![
TorrustTrackerUdpRunner::new(),
],
},
load_test_runs: simple_load_test_runs(cpu_mode, &[
(8, Priority::Medium),
Expand All @@ -111,6 +122,9 @@ impl UdpCommand {
UdpTracker::Chihaya => vec![
ChihayaUdpRunner::new(),
],
UdpTracker::TorrustTracker => vec![
TorrustTrackerUdpRunner::new(),
],
},
load_test_runs: simple_load_test_runs(cpu_mode, &[
(8, Priority::Medium),
Expand All @@ -131,6 +145,9 @@ impl UdpCommand {
UdpTracker::Chihaya => vec![
ChihayaUdpRunner::new(),
],
UdpTracker::TorrustTracker => vec![
TorrustTrackerUdpRunner::new(),
],
},
load_test_runs: simple_load_test_runs(cpu_mode, &[
(8, Priority::Medium),
Expand All @@ -151,6 +168,9 @@ impl UdpCommand {
UdpTracker::Chihaya => vec![
ChihayaUdpRunner::new(),
],
UdpTracker::TorrustTracker => vec![
TorrustTrackerUdpRunner::new(),
],
},
load_test_runs: simple_load_test_runs(cpu_mode, &[
(8, Priority::Medium),
Expand All @@ -171,6 +191,9 @@ impl UdpCommand {
UdpTracker::Chihaya => vec![
ChihayaUdpRunner::new(),
],
UdpTracker::TorrustTracker => vec![
TorrustTrackerUdpRunner::new(),
],
},
load_test_runs: simple_load_test_runs(cpu_mode, &[
(8, Priority::Medium),
Expand All @@ -191,6 +214,9 @@ impl UdpCommand {
UdpTracker::Chihaya => vec![
ChihayaUdpRunner::new(),
],
UdpTracker::TorrustTracker => vec![
TorrustTrackerUdpRunner::new(),
],
},
load_test_runs: simple_load_test_runs(cpu_mode, &[
(8, Priority::High),
Expand Down Expand Up @@ -385,6 +411,87 @@ impl ProcessRunner for ChihayaUdpRunner {
}
}

#[derive(Debug, Clone)]
struct TorrustTrackerUdpRunner;

impl TorrustTrackerUdpRunner {
#[allow(clippy::new_ret_no_self)]
fn new() -> Rc<dyn ProcessRunner<Command = UdpCommand>> {
Rc::new(Self {})
}
}

impl ProcessRunner for TorrustTrackerUdpRunner {
type Command = UdpCommand;

fn run(
&self,
command: &Self::Command,
vcpus: &TaskSetCpuList,
tmp_file: &mut NamedTempFile,
) -> anyhow::Result<Child> {
writedoc!(
tmp_file,
r#"
announce_interval = 120
db_driver = "Sqlite3"
db_path = "./sqlite3.db"
external_ip = "0.0.0.0"
inactive_peer_cleanup_interval = 600
log_level = "error"
max_peer_timeout = 900
min_announce_interval = 120
mode = "public"
on_reverse_proxy = false
persistent_torrent_completed_stat = false
remove_peerless_torrents = false
tracker_usage_statistics = false
[[udp_trackers]]
bind_address = "0.0.0.0:3000"
enabled = true
[[http_trackers]]
bind_address = "0.0.0.0:7070"
enabled = false
ssl_cert_path = ""
ssl_enabled = false
ssl_key_path = ""
[http_api]
bind_address = "127.0.0.1:1212"
enabled = false
ssl_cert_path = ""
ssl_enabled = false
ssl_key_path = ""
[http_api.access_tokens]
admin = "MyAccessToken"
[health_check_api]
bind_address = "127.0.0.1:1313"
"#,
)?;

Ok(Command::new("taskset")
.arg("--cpu-list")
.arg(vcpus.as_cpu_list())
.env("TORRUST_TRACKER_PATH_CONFIG", tmp_file.path())
.arg(&command.torrust_tracker)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?)
}

fn priority(&self) -> crate::common::Priority {
Priority::High
}

fn keys(&self) -> IndexMap<String, String> {
Default::default()
}
}

#[derive(Debug, Clone)]
struct AquaticUdpLoadTestRunner {
parameters: LoadTestRunnerParameters,
Expand Down

0 comments on commit dd1a5f9

Please sign in to comment.