v0.34.0_1

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-18 06:41:20 +02:00
1 parent 9cfc4588cc
commit f20c8da718
25 files changed
+694 -117

No files matched your search

+17 -4
View File
@@ -62,12 +62,25 @@ impl VhostMetrics {
Err(observed) => current = observed,
}
}
for (index, threshold) in DURATION_BUCKETS_US.iter().enumerate() {
if micros <= *threshold {
self.buckets[index].fetch_add(1, Ordering::Relaxed);
// Write exactly one exclusive histogram bin per exchange. Prometheus
// cumulative le=... buckets are reconstructed only when scraped.
// This removes up to 11 contended atomics for short 1 KiB responses.
let bucket = DURATION_BUCKETS_US.partition_point(|threshold| micros > *threshold);
self.buckets[bucket].fetch_add(1, Ordering::Relaxed);
}
/// A scrape-consistent cumulative representation of exclusive bins. The
/// sum of atomic snapshots is monotonic and the final count includes +Inf.
pub fn duration_histogram(&self) -> ([u64; DURATION_BUCKETS_US.len()], u64) {
let mut cumulative = [0u64; DURATION_BUCKETS_US.len()];
let mut count = 0u64;
for (index, bin) in self.buckets.iter().enumerate() {
count = count.saturating_add(bin.load(Ordering::Relaxed));
if index < DURATION_BUCKETS_US.len() {
cumulative[index] = count;
}
}
self.buckets[DURATION_BUCKETS_US.len()].fetch_add(1, Ordering::Relaxed);
(cumulative, count)
}
pub fn view(&self) -> VhostMetricsView {