Merge pull request #179 from greatest-ape/work-2024-01-27

README improvements; fix --no-default-features build errors
This commit is contained in:
Joakim Frostegård 2024-01-27 18:32:07 +01:00 committed by GitHub
commit f30ab82371
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 101 additions and 37 deletions

View file

@ -46,10 +46,10 @@ the table above.
## Copyright and license ## Copyright and license
Copyright (c) 2020-2023 Joakim Frostegård Copyright (c) Joakim Frostegård
Distributed under the terms of the Apache 2.0 license. Please refer to the Distributed under the terms of the Apache License, Version 2.0. Please refer to
`LICENSE` file in the repository root directory for details. the `LICENSE` file in the repository root directory for details.
## Trivia ## Trivia

View file

@ -1,3 +1,11 @@
# aquatic_bencher # aquatic_bencher
Automated benchmarking of aquatic and other BitTorrent trackers. Linux only. Automated benchmarking of aquatic and other BitTorrent trackers. Linux only.
## Supported trackers by protocol
### UDP
- [aquatic_udp](https://github.com/greatest-ape/aquatic/)
- [opentracker](https://erdgeist.org/arts/software/opentracker/)
- [chihaya](https://github.com/chihaya/chihaya)

View file

@ -26,6 +26,7 @@ pub struct SetConfig<C, I> {
pub load_test_runs: Vec<(usize, Priority, TaskSetCpuList)>, pub load_test_runs: Vec<(usize, Priority, TaskSetCpuList)>,
} }
#[allow(clippy::too_many_arguments)]
pub fn run_sets<C, F, I>( pub fn run_sets<C, F, I>(
command: &C, command: &C,
cpu_mode: CpuMode, cpu_mode: CpuMode,

View file

@ -24,11 +24,12 @@ More benchmark details are available [here](../../documents/aquatic-http-load-te
### Compiling ### Compiling
- Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended) - Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended)
- Install cmake with your package manager (e.g., `apt-get install cmake`) - Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`)
- Clone this git repository and enter its root directory - Clone this git repository and build the application:
- Build the application:
```sh ```sh
git clone https://github.com/greatest-ape/aquatic.git && cd aquatic
# Recommended: tell Rust to enable support for all SIMD extensions present on # Recommended: tell Rust to enable support for all SIMD extensions present on
# current CPU except for those relating to AVX-512. (If you run a processor # current CPU except for those relating to AVX-512. (If you run a processor
# that doesn't clock down when using AVX-512, you can enable those instructions # that doesn't clock down when using AVX-512, you can enable those instructions
@ -51,7 +52,8 @@ Make necessary adjustments to the file. You will likely want to adjust `address`
To run over TLS, configure certificate and private key files. To run over TLS, configure certificate and private key files.
Running behind a reverse proxy is supported. Running behind a reverse proxy is supported. Please refer to the config file
for details.
### Running ### Running
@ -83,7 +85,9 @@ configuration files in a similar manner to the tracker application.
After starting the tracker, run the load tester: After starting the tracker, run the load tester:
```sh ```sh
./scripts/run-load-test-http.sh . ./scripts/env-native-cpu-without-avx-512 # Optional
cargo build --release -p aquatic_http_load_test -- --help
``` ```
## Details ## Details
@ -107,7 +111,7 @@ fine in production.
## Copyright and license ## Copyright and license
Copyright (c) 2020-2023 Joakim Frostegård Copyright (c) Joakim Frostegård
Distributed under the terms of the Apache 2.0 license. Please refer to the Distributed under the terms of the Apache License, Version 2.0. Please refer to
`LICENSE` file in the repository root directory for details. the `LICENSE` file in the repository root directory for details.

View file

@ -99,6 +99,7 @@ impl TorrentMaps {
} }
} }
#[cfg(feature = "metrics")]
pub fn update_torrent_metrics(&self) { pub fn update_torrent_metrics(&self) {
self.ipv4.torrent_gauge.set(self.ipv4.torrents.len() as f64); self.ipv4.torrent_gauge.set(self.ipv4.torrents.len() as f64);
self.ipv6.torrent_gauge.set(self.ipv6.torrents.len() as f64); self.ipv6.torrent_gauge.set(self.ipv6.torrents.len() as f64);

View file

@ -7,9 +7,10 @@ authors.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
repository.workspace = true repository.workspace = true
readme.workspace = true
rust-version.workspace = true rust-version.workspace = true
readme = "./README.md"
[lib] [lib]
name = "aquatic_http_protocol" name = "aquatic_http_protocol"

View file

@ -0,0 +1,15 @@
# aquatic_http_protocol: HTTP BitTorrent tracker protocol
HTTP BitTorrent tracker message parsing and serialization.
[BEP 003]: https://www.bittorrent.org/beps/bep_0003.html
[BEP 007]: https://www.bittorrent.org/beps/bep_0007.html
[BEP 023]: https://www.bittorrent.org/beps/bep_0023.html
[BEP 048]: https://www.bittorrent.org/beps/bep_0048.html
Implements:
* [BEP 003]: HTTP BitTorrent protocol ([more details](https://wiki.theory.org/index.php/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol)). Exceptions:
* Only compact responses are supported
* [BEP 023]: Compact HTTP responses
* [BEP 007]: IPv6 support
* [BEP 048]: HTTP scrape support

View file

@ -6,9 +6,10 @@ authors.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
repository.workspace = true repository.workspace = true
readme.workspace = true
rust-version.workspace = true rust-version.workspace = true
readme = "./README.md"
[lib] [lib]
name = "aquatic_peer_id" name = "aquatic_peer_id"

3
crates/peer_id/README.md Normal file
View file

@ -0,0 +1,3 @@
# aquatic_peer_id
Extract BitTorrent client information from announce request peer IDs.

View file

@ -30,11 +30,12 @@ More benchmark details are available [here](../../documents/aquatic-udp-load-tes
### Compiling ### Compiling
- Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended) - Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended)
- Install cmake with your package manager (e.g., `apt-get install cmake`) - Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`)
- Clone this git repository and enter its root directory - Clone this git repository and build the application:
- Build the application:
```sh ```sh
git clone https://github.com/greatest-ape/aquatic.git && cd aquatic
# Recommended: tell Rust to enable support for all SIMD extensions present on # Recommended: tell Rust to enable support for all SIMD extensions present on
# current CPU except for those relating to AVX-512. (If you run a processor # current CPU except for those relating to AVX-512. (If you run a processor
# that doesn't clock down when using AVX-512, you can enable those instructions # that doesn't clock down when using AVX-512, you can enable those instructions
@ -73,7 +74,9 @@ configuration files in a similar manner to the tracker application.
After starting the tracker, run the load tester: After starting the tracker, run the load tester:
```sh ```sh
./scripts/run-load-test-udp.sh . ./scripts/env-native-cpu-without-avx-512 # Optional
cargo build --release -p aquatic_udp_load_test -- --help
``` ```
## Details ## Details
@ -85,7 +88,7 @@ Implements [BEP 015](https://www.bittorrent.org/beps/bep_0015.html) ([more detai
## Copyright and license ## Copyright and license
Copyright (c) 2020-2023 Joakim Frostegård Copyright (c) Joakim Frostegård
Distributed under the terms of the Apache 2.0 license. Please refer to the Distributed under the terms of the Apache License, Version 2.0. Please refer to
`LICENSE` file in the repository root directory for details. the `LICENSE` file in the repository root directory for details.

View file

@ -7,9 +7,10 @@ authors.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
repository.workspace = true repository.workspace = true
readme.workspace = true
rust-version.workspace = true rust-version.workspace = true
readme = "./README.md"
[dependencies] [dependencies]
aquatic_peer_id.workspace = true aquatic_peer_id.workspace = true

View file

@ -0,0 +1,4 @@
# aquatic_udp_protocol: UDP BitTorrent tracker protocol
[UDP BitTorrent](https://www.bittorrent.org/beps/bep_0015.html) tracker
message parsing and serialization.

View file

@ -28,11 +28,12 @@ More details are available [here](../../documents/aquatic-ws-load-test-2023-01-2
### Compiling ### Compiling
- Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended) - Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended)
- Install cmake with your package manager (e.g., `apt-get install cmake`) - Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`)
- Clone this git repository and enter its root directory - Clone this git repository and build the application:
- Build the application:
```sh ```sh
git clone https://github.com/greatest-ape/aquatic.git && cd aquatic
# Recommended: tell Rust to enable support for all SIMD extensions present on # Recommended: tell Rust to enable support for all SIMD extensions present on
# current CPU except for those relating to AVX-512. (If you run a processor # current CPU except for those relating to AVX-512. (If you run a processor
# that doesn't clock down when using AVX-512, you can enable those instructions # that doesn't clock down when using AVX-512, you can enable those instructions
@ -53,6 +54,8 @@ Generate the configuration file:
Make necessary adjustments to the file. You will likely want to adjust `address` Make necessary adjustments to the file. You will likely want to adjust `address`
(listening address) under the `network` section. (listening address) under the `network` section.
To run over TLS, configure certificate and private key files.
Running behind a reverse proxy is supported, as long as IPv4 requests are Running behind a reverse proxy is supported, as long as IPv4 requests are
proxied to IPv4 requests, and IPv6 requests to IPv6 requests. proxied to IPv4 requests, and IPv6 requests to IPv6 requests.
@ -86,7 +89,9 @@ configuration files in a similar manner to the tracker application.
After starting the tracker, run the load tester: After starting the tracker, run the load tester:
```sh ```sh
./scripts/run-load-test-ws.sh . ./scripts/env-native-cpu-without-avx-512 # Optional
cargo build --release -p aquatic_ws_load_test -- --help
``` ```
## Details ## Details
@ -102,8 +107,8 @@ fine in production.
## Copyright and license ## Copyright and license
Copyright (c) 2020-2023 Joakim Frostegård Copyright (c) Joakim Frostegård
Distributed under the terms of the Apache 2.0 license. Please refer to the Distributed under the terms of the Apache License, Version 2.0. Please refer to
`LICENSE` file in the repository root directory for details. the `LICENSE` file in the repository root directory for details.

View file

@ -42,6 +42,7 @@ use crate::workers::socket::calculate_in_message_consumer_index;
use crate::workers::socket::{ip_version_to_metrics_str, WORKER_INDEX}; use crate::workers::socket::{ip_version_to_metrics_str, WORKER_INDEX};
/// Optional second tuple field is for peer id hex representation /// Optional second tuple field is for peer id hex representation
#[cfg(feature = "metrics")]
type PeerClientGauge = (Gauge, Option<Gauge>); type PeerClientGauge = (Gauge, Option<Gauge>);
pub struct ConnectionRunner { pub struct ConnectionRunner {
@ -68,6 +69,7 @@ impl ConnectionRunner {
let clean_up_data = ConnectionCleanupData { let clean_up_data = ConnectionCleanupData {
announced_info_hashes: Default::default(), announced_info_hashes: Default::default(),
ip_version: self.ip_version, ip_version: self.ip_version,
#[cfg(feature = "metrics")]
opt_peer_client: Default::default(), opt_peer_client: Default::default(),
#[cfg(feature = "metrics")] #[cfg(feature = "metrics")]
active_connections_gauge: ::metrics::gauge!( active_connections_gauge: ::metrics::gauge!(
@ -597,6 +599,7 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionWriter<S> {
struct ConnectionCleanupData { struct ConnectionCleanupData {
announced_info_hashes: Rc<RefCell<HashMap<InfoHash, PeerId>>>, announced_info_hashes: Rc<RefCell<HashMap<InfoHash, PeerId>>>,
ip_version: IpVersion, ip_version: IpVersion,
#[cfg(feature = "metrics")]
opt_peer_client: Rc<RefCell<Option<PeerClientGauge>>>, opt_peer_client: Rc<RefCell<Option<PeerClientGauge>>>,
#[cfg(feature = "metrics")] #[cfg(feature = "metrics")]
active_connections_gauge: Gauge, active_connections_gauge: Gauge,

View file

@ -240,14 +240,14 @@ async fn clean_connections(
} }
}); });
#[cfg(feature = "metrics")]
{
::log::info!( ::log::info!(
"cleaned connections in worker {}, {} references remaining", "cleaned connections in worker {}, {} references remaining",
WORKER_INDEX.get(), WORKER_INDEX.get(),
connection_slab.borrow_mut().len() connection_slab.borrow_mut().len()
); );
#[cfg(feature = "metrics")]
{
// Increment gauges by zero to prevent them from being removed due to // Increment gauges by zero to prevent them from being removed due to
// idleness // idleness

View file

@ -176,6 +176,7 @@ impl TorrentMap {
server_start_instant, server_start_instant,
request_sender_meta, request_sender_meta,
&request, &request,
#[cfg(feature = "metrics")]
&self.peer_gauge, &self.peer_gauge,
); );
@ -260,7 +261,11 @@ impl TorrentMap {
pub fn handle_connection_closed(&mut self, info_hash: InfoHash, peer_id: PeerId) { pub fn handle_connection_closed(&mut self, info_hash: InfoHash, peer_id: PeerId) {
if let Some(torrent_data) = self.torrents.get_mut(&info_hash) { if let Some(torrent_data) = self.torrents.get_mut(&info_hash) {
torrent_data.handle_connection_closed(peer_id, &self.peer_gauge); torrent_data.handle_connection_closed(
peer_id,
#[cfg(feature = "metrics")]
&self.peer_gauge,
);
} }
} }

View file

@ -8,9 +8,10 @@ authors.workspace = true
edition.workspace = true edition.workspace = true
license.workspace = true license.workspace = true
repository.workspace = true repository.workspace = true
readme.workspace = true
rust-version.workspace = true rust-version.workspace = true
readme = "./README.md"
[lib] [lib]
name = "aquatic_ws_protocol" name = "aquatic_ws_protocol"

View file

@ -0,0 +1,4 @@
# aquatic_ws_protocol: WebTorrent tracker protocol
[WebTorrent](https://github.com/webtorrent) tracker message parsing and
serialization.

View file

@ -2,6 +2,10 @@
# aquatic_udp # aquatic_udp
# #
# Please note that running aquatic_udp under Docker is NOT RECOMMENDED due to
# suboptimal performance. This file is provided as a starting point for those
# who still wish to do so.
#
# Customize by setting CONFIG_FILE_CONTENTS and # Customize by setting CONFIG_FILE_CONTENTS and
# ACCESS_LIST_CONTENTS environment variables. # ACCESS_LIST_CONTENTS environment variables.
# #