Skip to content

Commit

Permalink
Make cpu usage check less frequent, and have it sleep BEFORE the firs…
Browse files Browse the repository at this point in the history
…t check.
  • Loading branch information
cyberw committed Dec 19, 2024
1 parent 0a1dbc4 commit 55b274a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
]
WORKER_REPORT_INTERVAL = 3.0
WORKER_LOG_REPORT_INTERVAL = 10
CPU_MONITOR_INTERVAL = 5.0
CPU_MONITOR_INTERVAL = 10.0
CPU_WARNING_THRESHOLD = 90
HEARTBEAT_INTERVAL = 1
HEARTBEAT_LIVENESS = 3
Expand Down Expand Up @@ -283,6 +283,7 @@ def stop_users(self, user_classes_stop_count: dict[str, int]) -> None:
def monitor_cpu_and_memory(self) -> NoReturn:
process = psutil.Process()
while True:
gevent.sleep(CPU_MONITOR_INTERVAL)
self.current_cpu_usage = process.cpu_percent()
self.current_memory_usage = process.memory_info().rss
if self.current_cpu_usage > CPU_WARNING_THRESHOLD:
Expand All @@ -296,7 +297,6 @@ def monitor_cpu_and_memory(self) -> NoReturn:
self.environment.events.usage_monitor.fire(
environment=self.environment, cpu_usage=self.current_cpu_usage, memory_usage=self.current_memory_usage
)
gevent.sleep(CPU_MONITOR_INTERVAL)

@abstractmethod
def start(
Expand Down

0 comments on commit 55b274a

Please sign in to comment.