Skip to content

Commit 89d6d42

Browse files
committed
build(deps): Bump lgalloc to 0.4.0
1 parent 65aae31 commit 89d6d42

File tree

7 files changed

+53
-17
lines changed

7 files changed

+53
-17
lines changed

Cargo.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/cargo-vet/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ version = "1.3.0"
572572
criteria = "safe-to-deploy"
573573

574574
[[exemptions.lgalloc]]
575-
version = "0.3.1"
575+
version = "0.4.0"
576576
criteria = "safe-to-deploy"
577577

578578
[[exemptions.libc]]

src/compute/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ differential-dataflow = "0.13.1"
2121
differential-dogs3 = "0.1.1"
2222
futures = "0.3.25"
2323
itertools = "0.10.5"
24-
lgalloc = "0.3"
24+
lgalloc = "0.4"
2525
mz-build-info = { path = "../build-info" }
2626
mz-cluster = { path = "../cluster" }
2727
mz-cluster-client = { path = "../cluster-client" }

src/metrics/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ publish = false
1010
workspace = true
1111

1212
[dependencies]
13-
lgalloc = "0.3"
13+
lgalloc = "0.4"
1414
libc = "0.2.138"
1515
mz-ore = { path = "../ore", features = ["metrics"] }
1616
paste = "1.0"
1717
prometheus = { version = "0.13.3", default-features = false }
18+
thiserror = "1.0.37"
1819
tokio = { version = "1.38.0", features = ["time"]}
20+
tracing = "0.1.37"
1921
workspace-hack = { version = "0.0.0", path = "../workspace-hack" }
2022

2123
[package.metadata.cargo-udeps.ignore]

src/metrics/src/lgalloc.rs

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,38 @@
88
use std::collections::BTreeMap;
99
use std::ops::AddAssign;
1010
use std::time::Duration;
11+
use tracing::error;
1112

1213
use lgalloc::{FileStats, SizeClassStats};
1314
use mz_ore::cast::CastFrom;
1415
use mz_ore::metrics::{raw, MetricsRegistry};
1516
use paste::paste;
1617
use prometheus::core::{AtomicU64, GenericGauge};
1718

19+
/// Error during FileStats
20+
#[derive(Debug, thiserror::Error)]
21+
#[error(transparent)]
22+
pub struct Error {
23+
/// Kind of error
24+
#[from]
25+
pub kind: ErrorKind,
26+
}
27+
28+
/// Kind of error during FileStats
29+
#[derive(Debug, thiserror::Error)]
30+
pub enum ErrorKind {
31+
/// Failed to get file stats
32+
#[error("Failed to get file stats: {0}")]
33+
FileStatsFailed(String),
34+
}
35+
36+
impl Error {
37+
/// Create a new error
38+
pub fn new(kind: ErrorKind) -> Error {
39+
Error { kind }
40+
}
41+
}
42+
1843
/// An accumulator for [`FileStats`].
1944
#[derive(Default)]
2045
struct FileStatsAccum {
@@ -57,7 +82,6 @@ macro_rules! metrics_size_class {
5782
) => {
5883
paste! {
5984
struct LgMetrics {
60-
stats: lgalloc::LgAllocStats,
6185
size_class: BTreeMap<usize, LgMetricsSC>,
6286
$($metric: raw::UIntGaugeVec,)*
6387
$($f_metric: raw::UIntGaugeVec,)*
@@ -70,7 +94,6 @@ macro_rules! metrics_size_class {
7094
fn new(registry: &MetricsRegistry) -> Self {
7195
Self {
7296
size_class: BTreeMap::default(),
73-
stats: lgalloc::LgAllocStats::default(),
7497
$($metric: registry.register(mz_ore::metric!(
7598
name: concat!(stringify!($namespace), "_", stringify!($metric)),
7699
help: $desc,
@@ -92,23 +115,29 @@ macro_rules! metrics_size_class {
92115
}
93116
})
94117
}
95-
fn update(&mut self) {
96-
let mut stats = std::mem::take(&mut self.stats);
97-
lgalloc::lgalloc_stats(&mut stats);
118+
fn update(&mut self) -> Result<(), Error> {
119+
let stats = lgalloc::lgalloc_stats();
98120
for sc in &stats.size_class {
99121
let sc_stats = self.get_size_class(sc.size_class);
100122
$(sc_stats.$metric.set(($conv)(u64::cast_from(sc.$name), sc));)*
101123
}
102124
let mut accums = BTreeMap::new();
103-
for file_stat in &stats.file_stats {
104-
let accum: &mut FileStatsAccum = accums.entry(file_stat.size_class).or_default();
105-
accum.add_assign(file_stat);
125+
match &stats.file_stats {
126+
Ok(file_stats) => {
127+
for file_stat in file_stats {
128+
let accum: &mut FileStatsAccum = accums.entry(file_stat.size_class).or_default();
129+
accum.add_assign(file_stat);
130+
}
131+
}
132+
Err(err) => {
133+
return Err(Error::new(ErrorKind::FileStatsFailed(err.to_string())));
134+
}
106135
}
107136
for (size_class, accum) in accums {
108137
let sc_stats = self.get_size_class(size_class);
109138
$(sc_stats.$f_metric.set(u64::cast_from(accum.$f_name));)*
110139
}
111-
self.stats = stats;
140+
Ok(())
112141
}
113142
}
114143
}
@@ -164,7 +193,10 @@ pub async fn register_metrics_into(metrics_registry: &MetricsRegistry) {
164193
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
165194
loop {
166195
interval.tick().await;
167-
lgmetrics.update();
196+
if let Err(err) = lgmetrics.update() {
197+
error!("{err}");
198+
break;
199+
}
168200
}
169201
});
170202
}

src/ore/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ flatcontainer = { version = "0.5.0", optional = true }
3232
futures = { version = "0.3.25", optional = true }
3333
hibitset = { version = "0.6.4", optional = true }
3434
itertools = "0.10.5"
35-
lgalloc = { version = "0.3", optional = true }
35+
lgalloc = { version = "0.4", optional = true }
3636
libc = { version = "0.2.138", optional = true }
3737
mz-ore-proc = { path = "../ore-proc", default-features = false }
3838
num = "0.4.0"

src/timely-util/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ columnation = "0.1.0"
1515
differential-dataflow = "0.13.1"
1616
either = "1"
1717
futures-util = "0.3.25"
18-
lgalloc = "0.3"
18+
lgalloc = "0.4"
1919
mz-ore = { path = "../ore", features = ["async", "process", "tracing_", "test"] }
2020
num-traits = "0.2"
2121
proptest = { version = "1.0.0", default-features = false, features = ["std"] }

0 commit comments

Comments
 (0)