proxy: scheduler: only do a single round of time alignment and drop counter

not much value in waiting an extra minute, that doesn't really
guarantees better scheduling (as in, less impact on startup).

Dropping that also allows easily to drop the counter by just moving
the sleep to the beginning of the loop.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-07-14 18:20:41 +02:00
parent 9f7752f2b2
commit 3f6a17b09f

View File

@ -527,15 +527,11 @@ fn next_minute() -> Instant {
}
async fn run_task_scheduler() {
let mut count: usize = 0;
loop {
count += 1;
// sleep first to align to next minute boundary for first round
let delay_target = next_minute();
tokio::time::sleep_until(tokio::time::Instant::from_std(delay_target)).await;
if count > 2 {
// wait 1..2 minutes before starting
match schedule_tasks().catch_unwind().await {
Err(panic) => match panic.downcast::<&str>() {
Ok(msg) => eprintln!("task scheduler panic: {msg}"),
@ -545,9 +541,6 @@ async fn run_task_scheduler() {
Ok(Ok(_)) => {}
}
}
tokio::time::sleep_until(tokio::time::Instant::from_std(delay_target)).await;
}
}
async fn schedule_tasks() -> Result<(), Error> {