Skip to content

Commit 0c42e18

Browse files
authored
metrics: don't make threads which submit metrics syscall to wake up (#7196)
Sleep without needing a notify.
1 parent 3297ff4 commit 0c42e18

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

metrics/src/metrics.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use {
44
crate::{counter::CounterPoint, datapoint::DataPoint},
5-
crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender},
5+
crossbeam_channel::{unbounded, Receiver, Sender, TryRecvError},
66
gethostname::gethostname,
77
log::*,
88
solana_cluster_type::ClusterType,
@@ -313,7 +313,7 @@ impl MetricsAgent {
313313
};
314314

315315
loop {
316-
match receiver.recv_timeout(write_frequency / 2) {
316+
match receiver.try_recv() {
317317
Ok(cmd) => match cmd {
318318
MetricsCommand::Flush(barrier) => {
319319
debug!("metrics_thread: flush");
@@ -334,12 +334,14 @@ impl MetricsAgent {
334334
}
335335
}
336336
},
337-
Err(RecvTimeoutError::Timeout) => (),
338-
Err(RecvTimeoutError::Disconnected) => {
337+
Err(TryRecvError::Empty) => {
338+
std::thread::sleep(Duration::from_millis(5));
339+
}
340+
Err(TryRecvError::Disconnected) => {
339341
debug!("run: sender disconnected");
340342
break;
341343
}
342-
}
344+
};
343345

344346
let now = Instant::now();
345347
if now.duration_since(last_write_time) >= write_frequency {

0 commit comments

Comments
 (0)