From c1c596a7fef56cb86a8a7673a3b9f9eb550d8065 Mon Sep 17 00:00:00 2001 From: tazlin Date: Mon, 4 Mar 2024 07:24:47 -0500 Subject: [PATCH] fix: clarify queue_size values; coerce suboptimal ones --- bridgeData_template.yaml | 2 +- horde_worker_regen/bridge_data/data_model.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bridgeData_template.yaml b/bridgeData_template.yaml index 33e555fc..afb0b221 100644 --- a/bridgeData_template.yaml +++ b/bridgeData_template.yaml @@ -17,7 +17,7 @@ priority_usernames: [] max_threads: 1 # We will keep this many requests in the queue so we can start working as soon as a thread is available -# This generally should be or 1, or 1 more the value of max_threads if max_threads is 2 or higher. +# This generally should be or 1 or 2. You should never set this higher than 2 if your max_threads is 2. queue_size: 1 # This will try to pull these many jobs per request and perform batched inference. diff --git a/horde_worker_regen/bridge_data/data_model.py b/horde_worker_regen/bridge_data/data_model.py index 8a3b6a8e..160caa4a 100644 --- a/horde_worker_regen/bridge_data/data_model.py +++ b/horde_worker_regen/bridge_data/data_model.py @@ -62,6 +62,18 @@ class reGenBridgeData(CombinedHordeBridgeData): @model_validator(mode="after") def validate_performance_modes(self) -> reGenBridgeData: + if self.max_threads == 2 and self.queue_size > 2: + self.queue_size = 2 + logger.warning( + "The queue_size value has been set to 2 because the max_threads value is 2.", + ) + + if self.max_threads > 2 and self.queue_size > 1: + self.queue_size = 1 + logger.warning( + "The queue_size value has been set to 1 because the max_threads value is greater than 2.", + ) + if self.high_memory_mode: if self.max_threads != 1: self.max_threads = 1