Skip to content

Commit

Permalink
fix: accurate mps pause logic
Browse files Browse the repository at this point in the history
The previous stand in of waiting a fixed number of seconds can be replaced by waiting an amount appropriate for the queue
  • Loading branch information
tazlin committed Mar 4, 2024
1 parent ca54615 commit 775b040
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions horde_worker_regen/process_management/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2372,14 +2372,14 @@ async def api_job_pop(self) -> None:
if self.should_wait_for_pending_megapixelsteps():
# Assuming a megapixelstep takes 0.75 seconds, if 2/3 of the time has passed since the limit was triggered,
# we can assume that the pending megapixelsteps will be below the limit soon. Otherwise we continue to wait
seconds_to_wait = (self._max_pending_megapixelsteps * 0.75) * (2 / 3)
seconds_to_wait = (self.get_pending_megapixelsteps() * 0.75) * (2 / 3)

if self.bridge_data.high_performance_mode:
seconds_to_wait *= 0.35
logger.debug("High performance mode is enabled, reducing the wait time by 70%")
# logger.debug("High performance mode is enabled, reducing the wait time by 70%")
elif self.bridge_data.moderate_performance_mode:
seconds_to_wait *= 0.5
logger.debug("Moderate performance mode is enabled, reducing the wait time by 50%")
# logger.debug("Moderate performance mode is enabled, reducing the wait time by 50%")

# if self.get_pending_megapixelsteps() > 200:
# seconds_to_wait = self._max_pending_megapixelsteps * 0.75
Expand All @@ -2393,9 +2393,13 @@ async def api_job_pop(self) -> None:
)
logger.debug(
f"Pending megapixelsteps: {self.get_pending_megapixelsteps()} | "
f"Max pending megapixelsteps: {self._max_pending_megapixelsteps} | ",
f"Max pending megapixelsteps: {self._max_pending_megapixelsteps} | "
f"Scheduled to wait for {seconds_to_wait} seconds",
)
logger.debug(
f"high_performance_mode: {self.bridge_data.high_performance_mode} | "
f"moderate_performance_mode: {self.bridge_data.moderate_performance_mode}",
)
return

if not (time.time() - self._triggered_max_pending_megapixelsteps_time) > seconds_to_wait:
Expand Down

0 comments on commit 775b040

Please sign in to comment.