Skip to content

Commit

Permalink
Relax atomic ordering on connection counter
Browse files Browse the repository at this point in the history
Ordering not required. No other data depends on this counter
  • Loading branch information
faern committed Dec 19, 2023
1 parent e26a70b commit 47eb17c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/statsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ mod real {
}

pub fn incr_connections(&self) {
let num_connections = self.num_connections.fetch_add(1, Ordering::SeqCst) + 1;
let num_connections = self.num_connections.fetch_add(1, Ordering::Relaxed) + 1;
log::debug!("Sending statsd num_connections = {num_connections}");
if let Err(e) = self.client.gauge("num_connections", num_connections) {
log::error!("Failed to emit statsd num_connections: {e}");
}
}

pub fn decr_connections(&self) {
let num_connections = self.num_connections.fetch_sub(1, Ordering::SeqCst) - 1;
let num_connections = self.num_connections.fetch_sub(1, Ordering::Relaxed) - 1;
log::debug!("Sending statsd num_connections = {num_connections}");
if let Err(e) = self.client.gauge("num_connections", num_connections) {
log::error!("Failed to emit statsd num_connections: {e}");
Expand Down

0 comments on commit 47eb17c

Please sign in to comment.