From 4c46b80f38670e0b0547db5aa88ca3579a4ceaf7 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 15 Sep 2025 14:19:02 -0400 Subject: [PATCH] motion_queuing: Further improve step flushing in batches Further encourage flushing steps in batches by delaying flushing if a batch isn't needed yet. Signed-off-by: Kevin O'Connor --- klippy/extras/motion_queuing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/klippy/extras/motion_queuing.py b/klippy/extras/motion_queuing.py index c2b306436..2371e9a2c 100644 --- a/klippy/extras/motion_queuing.py +++ b/klippy/extras/motion_queuing.py @@ -189,9 +189,11 @@ class PrinterMotionQueuing: want_sg_time = est_print_time + BGFLUSH_SG_HIGH_TIME batch_time = BGFLUSH_SG_HIGH_TIME - BGFLUSH_SG_LOW_TIME next_batch_time = self.last_step_gen_time + batch_time - if (next_batch_time > est_print_time - and next_batch_time < want_sg_time + 0.005): + if next_batch_time > est_print_time: # Improve run-to-run reproducibility by batching from last + if next_batch_time > want_sg_time: + # Delay flushing until next wakeup + next_batch_time = self.last_step_gen_time want_sg_time = next_batch_time want_sg_time = min(want_sg_time, aggr_sg_time) # Flush motion queues (if needed)