From 29bb696f3a2f7ffaf3cf81042e98a6aa9ed93d58 Mon Sep 17 00:00:00 2001 From: Bojan Serafimov Date: Thu, 20 Jul 2023 22:31:38 -0400 Subject: [PATCH] Don't distract startup with background threads --- compute_tools/src/bin/compute_ctl.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compute_tools/src/bin/compute_ctl.rs b/compute_tools/src/bin/compute_ctl.rs index 68f6bf3844..427ddf7206 100644 --- a/compute_tools/src/bin/compute_ctl.rs +++ b/compute_tools/src/bin/compute_ctl.rs @@ -222,11 +222,6 @@ fn main() -> Result<()> { compute.state_changed.notify_all(); drop(state); - // Launch remaining service threads - let _monitor_handle = launch_monitor(&compute).expect("cannot launch compute monitor thread"); - let _configurator_handle = - launch_configurator(&compute).expect("cannot launch configurator thread"); - // Start Postgres let mut delay_exit = false; let mut exit_code = None; @@ -243,6 +238,14 @@ fn main() -> Result<()> { } }; + // Launch remaining service threads + // + // NOTE we do this after starting postgres so that these two extra threads + // don't blow the cpu budget and throttle the startup process. + let _monitor_handle = launch_monitor(&compute).expect("cannot launch compute monitor thread"); + let _configurator_handle = + launch_configurator(&compute).expect("cannot launch configurator thread"); + // Wait for the child Postgres process forever. In this state Ctrl+C will // propagate to Postgres and it will be shut down as well. if let Some(mut pg) = pg {