mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic: print stats about number of peers per torrent
This commit is contained in:
parent
e3d3e9ab57
commit
51590a3d6c
4 changed files with 38 additions and 6 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
|
@ -24,6 +24,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bittorrent_udp",
|
"bittorrent_udp",
|
||||||
"dashmap",
|
"dashmap",
|
||||||
|
"histogram",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"mio",
|
"mio",
|
||||||
|
|
@ -244,6 +245,12 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "histogram"
|
||||||
|
version = "0.6.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "12cb882ccb290b8646e554b157ab0b71e64e8d5bef775cd66b6531e52d302669"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "humansize"
|
name = "humansize"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
|
||||||
6
TODO.md
6
TODO.md
|
|
@ -15,12 +15,6 @@
|
||||||
* Performance
|
* Performance
|
||||||
* cpu-target=native good?
|
* cpu-target=native good?
|
||||||
* mialloc good?
|
* mialloc good?
|
||||||
* use DashMap readable view when accessing torrent stats and possibly
|
|
||||||
also after modification of announcing peer and during collection
|
|
||||||
of response peers
|
|
||||||
* Statistics
|
|
||||||
* Print stats for number of peers per torrent (median, 95th, 99th
|
|
||||||
percentile.) Use histogram crate?
|
|
||||||
* bittorrent_udp
|
* bittorrent_udp
|
||||||
* ParseError enum maybe, with `Option<TransactionId>`
|
* ParseError enum maybe, with `Option<TransactionId>`
|
||||||
* Avoid allocating in conversion to bytes, send in a mutable buffer
|
* Avoid allocating in conversion to bytes, send in a mutable buffer
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ name = "aquatic"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bittorrent_udp = { path = "../bittorrent_udp" }
|
bittorrent_udp = { path = "../bittorrent_udp" }
|
||||||
dashmap = "3"
|
dashmap = "3"
|
||||||
|
histogram = "0.6"
|
||||||
indexmap = "1"
|
indexmap = "1"
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use histogram::Histogram;
|
||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod handlers;
|
pub mod handlers;
|
||||||
|
|
@ -55,6 +57,34 @@ pub fn run(){
|
||||||
responses_per_second,
|
responses_per_second,
|
||||||
requests_per_readable_event
|
requests_per_readable_event
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut peers_per_torrent = Histogram::new();
|
||||||
|
|
||||||
|
for torrent in state.torrents.iter(){
|
||||||
|
let num_seeders = torrent.num_seeders.load(Ordering::SeqCst);
|
||||||
|
let num_leechers = torrent.num_leechers.load(Ordering::SeqCst);
|
||||||
|
|
||||||
|
let num_peers = (num_seeders + num_leechers) as u64;
|
||||||
|
|
||||||
|
if let Err(err) = peers_per_torrent.increment(num_peers){
|
||||||
|
eprintln!("error incrementing peers_per_torrent histogram: {}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if peers_per_torrent.entries() != 0 {
|
||||||
|
println!(
|
||||||
|
"peers per torrent: min: {}, p50: {}, p75: {}, p90: {}, p99: {}, p999: {}, max: {}",
|
||||||
|
peers_per_torrent.minimum().unwrap(),
|
||||||
|
peers_per_torrent.percentile(50.0).unwrap(),
|
||||||
|
peers_per_torrent.percentile(75.0).unwrap(),
|
||||||
|
peers_per_torrent.percentile(90.0).unwrap(),
|
||||||
|
peers_per_torrent.percentile(99.0).unwrap(),
|
||||||
|
peers_per_torrent.percentile(99.9).unwrap(),
|
||||||
|
peers_per_torrent.maximum().unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
println!();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue