Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use C-style (percent) string formatting for all debug logging statements (improves performance) #2245

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion locust/main.py
Expand Up @@ -299,7 +299,7 @@ def stop_and_optionally_quit():
logger.info("--run-time limit reached, stopping test")
runner.stop()
if options.autoquit != -1:
logger.debug(f"Autoquit time limit set to {options.autoquit} seconds")
logger.debug("Autoquit time limit set to %s seconds" % options.autoquit)
time.sleep(options.autoquit)
logger.info("--autoquit time reached, shutting down")
runner.quit()
Expand Down
20 changes: 10 additions & 10 deletions locust/runners.py
Expand Up @@ -244,7 +244,7 @@ def spawn(user_class: str, spawn_count: int) -> List[User]:
n += 1
if n % 10 == 0 or n == spawn_count:
logger.debug("%i users spawned" % self.user_count)
logger.debug(f"All users of class {user_class} spawned")
logger.debug("All users of class %s spawned" % user_class)
return new_users

new_users: List[User] = []
Expand Down Expand Up @@ -283,7 +283,7 @@ def stop_users(self, user_classes_stop_count: Dict[str, int]) -> None:

while True:
user_to_stop: User = to_stop.pop()
logger.debug(f"Stopping {user_to_stop.greenlet.name}")
logger.debug("Stopping %s" % user_to_stop.greenlet.name)
if user_to_stop.greenlet is greenlet.getcurrent():
# User called runner.quit(), so don't block waiting for killing to finish
user_to_stop.group.killone(user_to_stop.greenlet, block=False)
Expand Down Expand Up @@ -508,7 +508,7 @@ def _start(self, user_count: int, spawn_rate: float, wait: bool = False, user_cl
user_classes_spawn_count: Dict[str, int] = {}
user_classes_stop_count: Dict[str, int] = {}
user_classes_count = dispatched_users[self._local_worker_node.id]
logger.debug(f"Ramping to {_format_user_classes_count_for_log(user_classes_count)}")
logger.debug("Ramping to %s" % _format_user_classes_count_for_log(user_classes_count))
for user_class_name, user_class_count in user_classes_count.items():
if self.user_classes_count[user_class_name] > user_class_count:
user_classes_stop_count[user_class_name] = (
Expand Down Expand Up @@ -571,7 +571,7 @@ def send_message(self, msg_type: str, data: Optional[Any] = None) -> None:
:param msg_type: The type of the message to emulate sending
:param data: Optional data to include
"""
logger.debug(f"Running locally: sending {msg_type} message to self")
logger.debug("Running locally: sending %s message to self" % msg_type)
if msg_type in self.custom_messages:
listener = self.custom_messages[msg_type]
msg = Message(msg_type, data, "local")
Expand Down Expand Up @@ -887,7 +887,7 @@ def stop(self, send_stop_to_client: bool = True) -> None:

if send_stop_to_client:
for client in self.clients.all:
logger.debug(f"Sending stop message to worker {client.id}")
logger.debug("Sending stop message to worker %s" % client.id)
self.server.send_to_client(Message("stop", None, client.id))

# Give an additional 60s for all workers to stop
Expand All @@ -906,7 +906,7 @@ def quit(self) -> None:
self.stop(send_stop_to_client=False)
logger.debug("Quitting...")
for client in self.clients.all:
logger.debug(f"Sending quit message to worker {client.id} (index {self.get_worker_index(client.id)})")
logger.debug("Sending quit message to worker %s (index %s)" % (client.id, self.get_worker_index(client.id)))
self.server.send_to_client(Message("quit", None, client.id))
gevent.sleep(0.5) # wait for final stats report from all workers
self.greenlet.kill(block=True)
Expand Down Expand Up @@ -1137,11 +1137,11 @@ def send_message(self, msg_type: str, data: Optional[Dict[str, Any]] = None, cli
If None, will send to all attached workers
"""
if client_id:
logger.debug(f"Sending {msg_type} message to worker {client_id}")
logger.debug("Sending %s message to worker %s" % (msg_type, client_id))
self.server.send_to_client(Message(msg_type, data, client_id))
else:
for client in self.clients.all:
logger.debug(f"Sending {msg_type} message to worker {client.id}")
logger.debug("Sending %s message to worker %s" % (msg_type, client_id))
self.server.send_to_client(Message(msg_type, data, client.id))


Expand Down Expand Up @@ -1346,7 +1346,7 @@ def worker(self) -> NoReturn:
logger.warning("Received reconnect message from master. Resetting RPC connection.")
self.reset_connection()
elif msg.type in self.custom_messages:
logger.debug(f"Received {msg.type} message from master")
logger.debug("Received %s message from master" % msg.type)
self.custom_messages[msg.type](environment=self.environment, msg=msg)
else:
logger.warning(f"Unknown message type received: {msg.type}")
Expand All @@ -1366,7 +1366,7 @@ def send_message(self, msg_type: str, data: Optional[Dict[str, Any]] = None) ->
:param msg_type: The type of the message to send
:param data: Optional data to send
"""
logger.debug(f"Sending {msg_type} message to master")
logger.debug("Sending %s message to master" % msg_type)
self.client.send(Message(msg_type, data, self.client_id))

def _send_stats(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions locust/test/test_dispatch.py
Expand Up @@ -1699,6 +1699,7 @@ class User3(User):
self.assertTrue(0 <= delta <= _TOLERANCE, delta)


@unittest.skip(reason="takes too long. run this manually if you change dispatch logic.")
class TestRampUpThenDownThenUp(unittest.TestCase):
def test_ramp_up_then_down_then_up(self):
for user1_weight, user2_weight, user3_weight, user4_weight, user5_weight in [
Expand Down
1 change: 1 addition & 0 deletions locust/test/test_runners.py
Expand Up @@ -1279,6 +1279,7 @@ def tick(self):
finally:
self.assertEqual(STATE_STOPPED, master.state)

@unittest.skip(reason="takes way too long (~45s)")
def test_distributed_shape_with_stop_timeout(self):
"""
Full integration test that starts both a MasterRunner and five WorkerRunner instances
Expand Down