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

[EASY] Parallelize post processing in run loop #3013

Merged
merged 2 commits into from
Sep 25, 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
46 changes: 16 additions & 30 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use {
solvable_orders::SolvableOrdersCache,
},
::observe::metrics,
anyhow::{Context, Result},
anyhow::Result,
database::order_events::OrderEventLabel,
ethcontract::U256,
ethrpc::block_stream::BlockInfo,
futures::future::BoxFuture,
futures::{future::BoxFuture, TryFutureExt},
itertools::Itertools,
model::solver_competition::{
CompetitionAuction,
Expand Down Expand Up @@ -458,28 +458,21 @@ impl RunLoop {
};

tracing::trace!(?competition, "saving competition");
self.persistence
.save_competition(&competition)
.await
.context("failed to save competition")?;

self.persistence
.save_surplus_capturing_jit_orders_orders(
auction_id,
&auction.surplus_capturing_jit_order_owners,
)
.await
.context("failed to save surplus capturing jit order owners")?;
futures::try_join!(
self.persistence
.save_competition(&competition)
.map_err(|e| e.0.context("failed to save competition")),
self.persistence
.save_surplus_capturing_jit_orders_orders(
auction_id,
&auction.surplus_capturing_jit_order_owners,
)
.map_err(|e| e.0.context("failed to save jit order owners")),
self.persistence
.store_fee_policies(auction_id, fee_policies)
.map_err(|e| e.context("failed to fee_policies")),
)?;

tracing::info!("saving fee policies");
if let Err(err) = self
.persistence
.store_fee_policies(auction_id, fee_policies)
.await
{
Metrics::fee_policies_store_error();
tracing::warn!(?err, "failed to save fee policies");
}
Metrics::post_processed(start.elapsed());
Ok(())
}
Expand Down Expand Up @@ -1013,13 +1006,6 @@ impl Metrics {
.inc_by(unsettled.len() as u64);
}

fn fee_policies_store_error() {
Self::get()
.db_metric_error
.with_label_values(&["fee_policies_store"])
.inc();
}

fn post_processed(elapsed: Duration) {
Self::get()
.auction_postprocessing_time
Expand Down
Loading