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

fix(witness_generator): Only spawn 1 prometheus exporter per witness generator #2492

Merged
merged 2 commits into from
Jul 26, 2024
Merged
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
37 changes: 18 additions & 19 deletions prover/crates/bin/witness_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,32 @@ async fn main() -> anyhow::Result<()> {
}
};

let prometheus_config = if use_push_gateway {
let prometheus_config = prometheus_config
.clone()
.context("prometheus config needed when use_push_gateway enabled")?;
PrometheusExporterConfig::push(
prometheus_config
.gateway_endpoint()
.context("gateway_endpoint needed when use_push_gateway enabled")?,
prometheus_config.push_interval(),
)
} else {
PrometheusExporterConfig::pull(prometheus_listener_port as u16)
};
let prometheus_task = prometheus_config.run(stop_receiver.clone());

let mut tasks = Vec::new();
tasks.push(tokio::spawn(prometheus_task));

for (i, round) in rounds.iter().enumerate() {
for round in rounds {
tracing::info!(
"initializing the {:?} witness generator, batch size: {:?} with protocol_version: {:?}",
round,
opt.batch_size,
&protocol_version
);

let prometheus_config = if use_push_gateway {
let prometheus_config = prometheus_config
.clone()
.context("prometheus config needed when use_push_gateway enabled")?;
PrometheusExporterConfig::push(
prometheus_config
.gateway_endpoint()
.context("gateway_endpoint needed when use_push_gateway enabled")?,
prometheus_config.push_interval(),
)
} else {
// `u16` cast is safe since i is in range [0, 4)
PrometheusExporterConfig::pull(prometheus_listener_port + i as u16)
};
let prometheus_task = prometheus_config.run(stop_receiver.clone());

let witness_generator_task = match round {
AggregationRound::BasicCircuits => {
let setup_data_path = prover_config.setup_data_path.clone();
Expand Down Expand Up @@ -276,15 +276,14 @@ async fn main() -> anyhow::Result<()> {
}
};

tasks.push(tokio::spawn(prometheus_task));
tasks.push(tokio::spawn(witness_generator_task));

tracing::info!(
"initialized {:?} witness generator in {:?}",
round,
started_at.elapsed()
);
SERVER_METRICS.init_latency[&(*round).into()].set(started_at.elapsed());
SERVER_METRICS.init_latency[&round.into()].set(started_at.elapsed());
}

let (mut stop_signal_sender, mut stop_signal_receiver) = mpsc::channel(256);
Expand Down
Loading