Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): Bump lgalloc to 0.4.0 #30606

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion misc/cargo-vet/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ version = "1.3.0"
criteria = "safe-to-deploy"

[[exemptions.lgalloc]]
version = "0.3.1"
version = "0.4.0"
criteria = "safe-to-deploy"

[[exemptions.libc]]
Expand Down
2 changes: 1 addition & 1 deletion src/compute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ differential-dataflow = "0.13.1"
differential-dogs3 = "0.1.1"
futures = "0.3.25"
itertools = "0.10.5"
lgalloc = "0.3"
lgalloc = "0.4"
mz-build-info = { path = "../build-info" }
mz-cluster = { path = "../cluster" }
mz-cluster-client = { path = "../cluster-client" }
Expand Down
4 changes: 3 additions & 1 deletion src/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ publish = false
workspace = true

[dependencies]
lgalloc = "0.3"
lgalloc = "0.4"
libc = "0.2.138"
mz-ore = { path = "../ore", features = ["metrics"] }
paste = "1.0"
prometheus = { version = "0.13.3", default-features = false }
thiserror = "1.0.37"
tokio = { version = "1.38.0", features = ["time"]}
tracing = "0.1.37"
workspace-hack = { version = "0.0.0", path = "../workspace-hack" }

[package.metadata.cargo-udeps.ignore]
Expand Down
52 changes: 42 additions & 10 deletions src/metrics/src/lgalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,38 @@
use std::collections::BTreeMap;
use std::ops::AddAssign;
use std::time::Duration;
use tracing::error;

use lgalloc::{FileStats, SizeClassStats};
use mz_ore::cast::CastFrom;
use mz_ore::metrics::{raw, MetricsRegistry};
use paste::paste;
use prometheus::core::{AtomicU64, GenericGauge};

/// Error during FileStats
#[derive(Debug, thiserror::Error)]
#[error(transparent)]
pub struct Error {
/// Kind of error
#[from]
pub kind: ErrorKind,
}

/// Kind of error during FileStats
#[derive(Debug, thiserror::Error)]
pub enum ErrorKind {
/// Failed to get file stats
#[error("Failed to get file stats: {0}")]
FileStatsFailed(String),
}

impl Error {
/// Create a new error
pub fn new(kind: ErrorKind) -> Error {
Error { kind }
}
}

/// An accumulator for [`FileStats`].
#[derive(Default)]
struct FileStatsAccum {
Expand Down Expand Up @@ -57,7 +82,6 @@ macro_rules! metrics_size_class {
) => {
paste! {
struct LgMetrics {
stats: lgalloc::LgAllocStats,
size_class: BTreeMap<usize, LgMetricsSC>,
$($metric: raw::UIntGaugeVec,)*
$($f_metric: raw::UIntGaugeVec,)*
Expand All @@ -70,7 +94,6 @@ macro_rules! metrics_size_class {
fn new(registry: &MetricsRegistry) -> Self {
Self {
size_class: BTreeMap::default(),
stats: lgalloc::LgAllocStats::default(),
$($metric: registry.register(mz_ore::metric!(
name: concat!(stringify!($namespace), "_", stringify!($metric)),
help: $desc,
Expand All @@ -92,23 +115,29 @@ macro_rules! metrics_size_class {
}
})
}
fn update(&mut self) {
let mut stats = std::mem::take(&mut self.stats);
lgalloc::lgalloc_stats(&mut stats);
fn update(&mut self) -> Result<(), Error> {
let stats = lgalloc::lgalloc_stats();
for sc in &stats.size_class {
let sc_stats = self.get_size_class(sc.size_class);
$(sc_stats.$metric.set(($conv)(u64::cast_from(sc.$name), sc));)*
}
let mut accums = BTreeMap::new();
for file_stat in &stats.file_stats {
let accum: &mut FileStatsAccum = accums.entry(file_stat.size_class).or_default();
accum.add_assign(file_stat);
match &stats.file_stats {
Ok(file_stats) => {
for file_stat in file_stats {
let accum: &mut FileStatsAccum = accums.entry(file_stat.size_class).or_default();
accum.add_assign(file_stat);
}
}
Err(err) => {
return Err(Error::new(ErrorKind::FileStatsFailed(err.to_string())));
}
}
for (size_class, accum) in accums {
let sc_stats = self.get_size_class(size_class);
$(sc_stats.$f_metric.set(u64::cast_from(accum.$f_name));)*
}
self.stats = stats;
Ok(())
}
}
}
Expand Down Expand Up @@ -164,7 +193,10 @@ pub async fn register_metrics_into(metrics_registry: &MetricsRegistry) {
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
loop {
interval.tick().await;
lgmetrics.update();
if let Err(err) = lgmetrics.update() {
error!("lgalloc stats update failed: {err}");
break;
}
}
});
}
2 changes: 1 addition & 1 deletion src/ore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ flatcontainer = { version = "0.5.0", optional = true }
futures = { version = "0.3.25", optional = true }
hibitset = { version = "0.6.4", optional = true }
itertools = "0.10.5"
lgalloc = { version = "0.3", optional = true }
lgalloc = { version = "0.4", optional = true }
libc = { version = "0.2.138", optional = true }
mz-ore-proc = { path = "../ore-proc", default-features = false }
num = "0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion src/timely-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ columnation = "0.1.0"
differential-dataflow = "0.13.1"
either = "1"
futures-util = "0.3.25"
lgalloc = "0.3"
lgalloc = "0.4"
mz-ore = { path = "../ore", features = ["async", "process", "tracing_", "test"] }
num-traits = "0.2"
proptest = { version = "1.0.0", default-features = false, features = ["std"] }
Expand Down
Loading