diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2023-12-30 11:43:32 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2023-12-30 11:43:32 -0500 |
commit | 9847b44901dfd130c0e07edc9a4ee072417af975 (patch) | |
tree | 5dd0a1b7b5851a997d21e47a291c68b3f340109c /klippy/toolhead.py | |
parent | d7f6348ae6e45e4b566d10974b10ab4bb111222b (diff) | |
download | kutter-9847b44901dfd130c0e07edc9a4ee072417af975.tar.gz kutter-9847b44901dfd130c0e07edc9a4ee072417af975.tar.xz kutter-9847b44901dfd130c0e07edc9a4ee072417af975.zip |
toolhead: Avoid calling reactor.monotonic() on each _advance_flush_time()
Move calculation of clear_history_time to the callers of
_advance_flush_time() as a minor processing optimization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r-- | klippy/toolhead.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 051a2c30..3bc74cac 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -281,7 +281,7 @@ class ToolHead: for module_name in modules: self.printer.load_object(config, module_name) # Print time and flush tracking - def _advance_flush_time(self, flush_time): + def _advance_flush_time(self, flush_time, clear_history_time): flush_time = max(flush_time, self.last_flush_time) # Generate steps via itersolve sg_flush_want = min(flush_time + STEPCOMPRESS_FLUSH_TIME, @@ -290,8 +290,6 @@ class ToolHead: for sg in self.step_generators: sg(sg_flush_time) self.last_sg_flush_time = sg_flush_time - clear_history_time = self.mcu.estimated_print_time( - self.reactor.monotonic() - MOVE_HISTORY_EXPIRE) # Free trapq entries that are no longer needed free_time = sg_flush_time - self.kin_flush_delay self.trapq_finalize_moves(self.trapq, free_time, clear_history_time) @@ -305,9 +303,11 @@ class ToolHead: flush_time = max(self.last_flush_time, self.print_time - pt_delay) self.print_time = max(self.print_time, next_print_time) want_flush_time = max(flush_time, self.print_time - pt_delay) + clear_history_time = self.mcu.estimated_print_time( + self.reactor.monotonic()) - MOVE_HISTORY_EXPIRE while 1: flush_time = min(flush_time + MOVE_BATCH_TIME, want_flush_time) - self._advance_flush_time(flush_time) + self._advance_flush_time(flush_time, clear_history_time) if flush_time >= want_flush_time: break def _calc_print_time(self): @@ -359,7 +359,7 @@ class ToolHead: self.check_stall_time = 0. def flush_step_generation(self): self._flush_lookahead() - self._advance_flush_time(self.step_gen_time) + self._advance_flush_time(self.step_gen_time, 0.) def get_last_move_time(self): if self.special_queuing_state: self._flush_lookahead() @@ -433,7 +433,8 @@ class ToolHead: if buffer_time > BGFLUSH_LOW_TIME: return eventtime + buffer_time - BGFLUSH_LOW_TIME ftime = est_print_time + BGFLUSH_LOW_TIME + BGFLUSH_BATCH_TIME - self._advance_flush_time(min(self.need_flush_time, ftime)) + self._advance_flush_time(min(self.need_flush_time, ftime), + est_print_time - MOVE_HISTORY_EXPIRE) except: logging.exception("Exception in flush_handler") self.printer.invoke_shutdown("Exception in flush_handler") |