Skip to content

Commit 36cc6a7

Browse files
Only start emitting metrics after initialization
1 parent dfc9c00 commit 36cc6a7

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

quic/s2n-quic-bench/src/bin/overload-server.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use s2n_quic_dc::{
1717
use s2n_quic_dc_metrics::{Registry, Unit};
1818
use std::{
1919
net::Ipv4Addr,
20-
sync::Arc,
20+
sync::{Arc, Barrier},
2121
time::{Duration, Instant},
2222
};
2323
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
@@ -101,13 +101,16 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
101101

102102
let server_name: s2n_quic::server::Name = "localhost".into();
103103

104+
let num_groups = concurrency.div_ceil(5);
105+
let barrier = Arc::new(Barrier::new(num_groups + 1));
106+
104107
// A redirect socket sits between a client <-> redirect <-> server.
105108
//
106109
// Clients can only handshake with up to 5 *distinct* server addresses, so having the redirect
107110
// in the middle allows us to treat the single server as many different servers. Each client we
108111
// spin up gets a set of 5 redirect sockets which we read/write from to get to the actual
109112
// server.
110-
for _ in 0..concurrency.div_ceil(5) {
113+
for _ in 0..num_groups {
111114
let tls = (certificates::CERT_PEM, certificates::KEY_PEM);
112115
let sub = s2n_quic::provider::event::disabled::Subscriber;
113116

@@ -170,6 +173,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
170173

171174
let metrics = metrics.clone();
172175
let server_name = server_name.clone();
176+
let barrier = barrier.clone();
173177
std::thread::spawn(move || {
174178
let rt = tokio::runtime::Builder::new_current_thread()
175179
.enable_all()
@@ -178,6 +182,7 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
178182

179183
rt.block_on(async move {
180184
let mut futs = tokio::task::JoinSet::new();
185+
let mut first = true;
181186
loop {
182187
let start = Instant::now();
183188
for addr in addrs.iter().copied() {
@@ -190,11 +195,21 @@ fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
190195
while let Some(Ok(res)) = futs.join_next().await {
191196
metrics.record(res.is_ok(), start.elapsed());
192197
}
198+
if first {
199+
first = false;
200+
barrier.wait();
201+
}
193202
}
194203
});
195204
});
196205
}
197206

207+
barrier.wait();
208+
209+
// Skip the first metrics line (warmup)
210+
std::thread::sleep(Duration::from_secs(1));
211+
let _ = registry.take_current_metrics_line();
212+
198213
loop {
199214
std::thread::sleep(Duration::from_secs(1));
200215
let line = registry.take_current_metrics_line();

0 commit comments

Comments
 (0)