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

Refactoring of the dispatch logic to improve performance #1809

Merged
merged 26 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
694e83e
Optimization of dispatch
mboutet Jul 7, 2021
59f77db
WIP on new dispatch code + distribution refactor
mboutet Jul 7, 2021
5c996b3
[WIP] Remove unused code + remove distribution logic
mboutet Jul 7, 2021
be8e004
Comment print in dispatcher
mboutet Jul 7, 2021
4868c9a
Include `roundrobin` in the dependencies
mboutet Jul 7, 2021
86b7923
Change wording in TODO
mboutet Jul 7, 2021
3036c62
Simplify if-elif-else
mboutet Jul 7, 2021
dce5f30
Improve handling of ramp-down
mboutet Jul 8, 2021
73c8f92
Remove commented code
mboutet Jul 8, 2021
9f84e78
Handle disconnecting/connecting workers
mboutet Jul 9, 2021
7c4bd3f
Handle initialized users dispatcher when worker goes missing
mboutet Jul 9, 2021
a47963b
Fix ramp-down when spawn rate greater than number of users to stop
mboutet Jul 9, 2021
fc6f886
Improve perf of `_user_gen` by using `itertools.cycle`
mboutet Jul 9, 2021
b7c2d3b
Remove TODOs that are no longer applicable
mboutet Jul 9, 2021
32ba957
Update some tests to work with refactor
mboutet Jul 9, 2021
0309453
Implement more test cases for dispatch
mboutet Jul 9, 2021
fd14a0b
Perf improvement for dispatch
mboutet Jul 9, 2021
b9c5dd4
Small script to benchmark dispatcher
mboutet Jul 9, 2021
f9adde1
Some scripts I use to manually test locust locally
mboutet Jul 9, 2021
72ed364
Improve benchmark script
mboutet Jul 11, 2021
a0360e2
Small perf improvement in dispatch
mboutet Jul 11, 2021
15b76a8
Add TODO
mboutet Jul 11, 2021
6a8130c
Update tests to make them pass
mboutet Jul 11, 2021
06d8498
Relax pass criteria
mboutet Jul 11, 2021
0c1bc35
Ensure there's at least one user class when instantiating the dispatcher
mboutet Jul 11, 2021
55f0a75
Instantiating the dispatcher in start for the LocalRunner
mboutet Jul 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
617 changes: 101 additions & 516 deletions locust/dispatch.py

Large diffs are not rendered by default.

115 changes: 0 additions & 115 deletions locust/distribution.py

This file was deleted.

5 changes: 2 additions & 3 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from . import User
from locust import __version__
from .dispatch import UsersDispatcher
from .distribution import weight_users
from .exception import RPCError
from .log import greenlet_exception_logger
from .rpc import (
Expand Down Expand Up @@ -299,7 +298,7 @@ def start(self, user_count: int, spawn_rate: float, wait: bool = False):
if self.environment.host is not None:
user_class.host = self.environment.host

self.target_user_classes_count = weight_users(self.user_classes, user_count)
self.target_user_classes_count = distribute_users(self.user_classes, user_count)

local_worker_node = WorkerNode(id="local")
local_worker_node.user_classes_count = self.user_classes_count
Expand Down Expand Up @@ -642,7 +641,7 @@ def start(self, user_count: int, spawn_rate: float, **kwargs) -> None:
if self.environment.host is not None:
user_class.host = self.environment.host

self.target_user_classes_count = weight_users(self.user_classes, user_count)
self.target_user_classes_count = distribute_users(self.user_classes, user_count)

self.spawn_rate = spawn_rate

Expand Down
Loading