Skip to content

Commit

Permalink
Merge pull request #179 from greatest-ape/work-2024-01-27
Browse files Browse the repository at this point in the history
README improvements; fix --no-default-features build errors
  • Loading branch information
greatest-ape authored Jan 27, 2024
2 parents b356e30 + 964636d commit f30ab82
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 37 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ the table above.

## 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
`LICENSE` file in the repository root directory for details.
Distributed under the terms of the Apache License, Version 2.0. Please refer to
the `LICENSE` file in the repository root directory for details.

## Trivia

Expand Down
10 changes: 9 additions & 1 deletion crates/bencher/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 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)
1 change: 1 addition & 0 deletions crates/bencher/src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct SetConfig<C, I> {
pub load_test_runs: Vec<(usize, Priority, TaskSetCpuList)>,
}

#[allow(clippy::too_many_arguments)]
pub fn run_sets<C, F, I>(
command: &C,
cpu_mode: CpuMode,
Expand Down
20 changes: 12 additions & 8 deletions crates/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ More benchmark details are available [here](../../documents/aquatic-http-load-te
### Compiling

- Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended)
- Install cmake with your package manager (e.g., `apt-get install cmake`)
- Clone this git repository and enter its root directory
- Build the application:
- Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`)
- Clone this git repository and build the application:

```sh
git clone https://github.com/greatest-ape/aquatic.git && cd aquatic

# 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
# that doesn't clock down when using AVX-512, you can enable those instructions
Expand All @@ -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.

Running behind a reverse proxy is supported.
Running behind a reverse proxy is supported. Please refer to the config file
for details.

### Running

Expand Down Expand Up @@ -83,7 +85,9 @@ configuration files in a similar manner to the tracker application.
After starting the tracker, run the load tester:

```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
Expand All @@ -107,7 +111,7 @@ fine in production.

## 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
`LICENSE` file in the repository root directory for details.
Distributed under the terms of the Apache License, Version 2.0. Please refer to
the `LICENSE` file in the repository root directory for details.
1 change: 1 addition & 0 deletions crates/http/src/workers/swarm/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ impl TorrentMaps {
}
}

#[cfg(feature = "metrics")]
pub fn update_torrent_metrics(&self) {
self.ipv4.torrent_gauge.set(self.ipv4.torrents.len() as f64);
self.ipv6.torrent_gauge.set(self.ipv6.torrents.len() as f64);
Expand Down
3 changes: 2 additions & 1 deletion crates/http_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
rust-version.workspace = true

readme = "./README.md"

[lib]
name = "aquatic_http_protocol"

Expand Down
15 changes: 15 additions & 0 deletions crates/http_protocol/README.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion crates/peer_id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
rust-version.workspace = true

readme = "./README.md"

[lib]
name = "aquatic_peer_id"

Expand Down
3 changes: 3 additions & 0 deletions crates/peer_id/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# aquatic_peer_id

Extract BitTorrent client information from announce request peer IDs.
17 changes: 10 additions & 7 deletions crates/udp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ More benchmark details are available [here](../../documents/aquatic-udp-load-tes
### Compiling

- Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended)
- Install cmake with your package manager (e.g., `apt-get install cmake`)
- Clone this git repository and enter its root directory
- Build the application:
- Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`)
- Clone this git repository and build the application:

```sh
git clone https://github.com/greatest-ape/aquatic.git && cd aquatic

# 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
# that doesn't clock down when using AVX-512, you can enable those instructions
Expand Down Expand Up @@ -73,7 +74,9 @@ configuration files in a similar manner to the tracker application.
After starting the tracker, run the load tester:

```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
Expand All @@ -85,7 +88,7 @@ Implements [BEP 015](https://www.bittorrent.org/beps/bep_0015.html) ([more detai

## 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
`LICENSE` file in the repository root directory for details.
Distributed under the terms of the Apache License, Version 2.0. Please refer to
the `LICENSE` file in the repository root directory for details.
3 changes: 2 additions & 1 deletion crates/udp_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
rust-version.workspace = true

readme = "./README.md"

[dependencies]
aquatic_peer_id.workspace = true

Expand Down
4 changes: 4 additions & 0 deletions crates/udp_protocol/README.md
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 12 additions & 7 deletions crates/ws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ More details are available [here](../../documents/aquatic-ws-load-test-2023-01-2
### Compiling

- Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended)
- Install cmake with your package manager (e.g., `apt-get install cmake`)
- Clone this git repository and enter its root directory
- Build the application:
- Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`)
- Clone this git repository and build the application:

```sh
git clone https://github.com/greatest-ape/aquatic.git && cd aquatic

# 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
# that doesn't clock down when using AVX-512, you can enable those instructions
Expand All @@ -53,6 +54,8 @@ Generate the configuration file:
Make necessary adjustments to the file. You will likely want to adjust `address`
(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
proxied to IPv4 requests, and IPv6 requests to IPv6 requests.

Expand Down Expand Up @@ -86,7 +89,9 @@ configuration files in a similar manner to the tracker application.
After starting the tracker, run the load tester:

```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
Expand All @@ -102,8 +107,8 @@ fine in production.

## 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
`LICENSE` file in the repository root directory for details.
Distributed under the terms of the Apache License, Version 2.0. Please refer to
the `LICENSE` file in the repository root directory for details.

3 changes: 3 additions & 0 deletions crates/ws/src/workers/socket/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use crate::workers::socket::calculate_in_message_consumer_index;
use crate::workers::socket::{ip_version_to_metrics_str, WORKER_INDEX};

/// Optional second tuple field is for peer id hex representation
#[cfg(feature = "metrics")]
type PeerClientGauge = (Gauge, Option<Gauge>);

pub struct ConnectionRunner {
Expand All @@ -68,6 +69,7 @@ impl ConnectionRunner {
let clean_up_data = ConnectionCleanupData {
announced_info_hashes: Default::default(),
ip_version: self.ip_version,
#[cfg(feature = "metrics")]
opt_peer_client: Default::default(),
#[cfg(feature = "metrics")]
active_connections_gauge: ::metrics::gauge!(
Expand Down Expand Up @@ -597,6 +599,7 @@ impl<S: futures::AsyncRead + futures::AsyncWrite + Unpin> ConnectionWriter<S> {
struct ConnectionCleanupData {
announced_info_hashes: Rc<RefCell<HashMap<InfoHash, PeerId>>>,
ip_version: IpVersion,
#[cfg(feature = "metrics")]
opt_peer_client: Rc<RefCell<Option<PeerClientGauge>>>,
#[cfg(feature = "metrics")]
active_connections_gauge: Gauge,
Expand Down
12 changes: 6 additions & 6 deletions crates/ws/src/workers/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ async fn clean_connections(
}
});

::log::info!(
"cleaned connections in worker {}, {} references remaining",
WORKER_INDEX.get(),
connection_slab.borrow_mut().len()
);

#[cfg(feature = "metrics")]
{
::log::info!(
"cleaned connections in worker {}, {} references remaining",
WORKER_INDEX.get(),
connection_slab.borrow_mut().len()
);

// Increment gauges by zero to prevent them from being removed due to
// idleness

Expand Down
7 changes: 6 additions & 1 deletion crates/ws/src/workers/swarm/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl TorrentMap {
server_start_instant,
request_sender_meta,
&request,
#[cfg(feature = "metrics")]
&self.peer_gauge,
);

Expand Down Expand Up @@ -260,7 +261,11 @@ impl TorrentMap {

pub fn handle_connection_closed(&mut self, info_hash: InfoHash, peer_id: PeerId) {
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,
);
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/ws_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
readme.workspace = true
rust-version.workspace = true

readme = "./README.md"

[lib]
name = "aquatic_ws_protocol"

Expand Down
4 changes: 4 additions & 0 deletions crates/ws_protocol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# aquatic_ws_protocol: WebTorrent tracker protocol

[WebTorrent](https://github.com/webtorrent) tracker message parsing and
serialization.
4 changes: 4 additions & 0 deletions docker/aquatic_udp.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# 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
# ACCESS_LIST_CONTENTS environment variables.
#
Expand Down

0 comments on commit f30ab82

Please sign in to comment.