-
Notifications
You must be signed in to change notification settings - Fork 24
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
Cosmetics changes to improve readability, types, and upgrades #185
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #185 +/- ##
==========================================
- Coverage 75.19% 74.87% -0.33%
==========================================
Files 31 31
Lines 1165 1170 +5
==========================================
Hits 876 876
- Misses 289 294 +5 ☔ View full report in Codecov by Sentry. |
If the test has some deviation on the behaviour of clients according to their IDs, for example if every N clients the Nth will do extra work, then the distribution of clients across supervisors might not be uniform. For this, prefer hashing them.
@@ -73,7 +73,7 @@ terminate(Scenario, State) -> | |||
%% if scenario module exports both functions, `Scenario:start/2' is used. | |||
%% | |||
%% Runs on the user process and spans a `[amoc, scenario, user, _]' telemetry event. | |||
-spec start(amoc:scenario(), user_id(), state()) -> any(). | |||
-spec start(amoc:scenario(), user_id(), state()) -> term(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any()
highlights that returned value is ignored.
-define(WORKER(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}). | ||
-define(SUP(I, Type), {I, {I, start_link, []}, permanent, infinity, Type, [I]}). | ||
-define(WORKER(I), {I, {I, start_link, []}, permanent, 5000, worker, [I]}). | ||
-define(SUP(I), {I, {I, start_link, []}, permanent, infinity, supervisor, [I]}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this was a bit stupid :)
@@ -139,14 +139,14 @@ terminate_all_children() -> | |||
-spec get_sup_for_user_id(amoc_scenario:user_id()) -> pid(). | |||
get_sup_for_user_id(Id) -> | |||
#storage{sups = Supervisors, sups_count = SupCount} = persistent_term:get(?MODULE), | |||
Index = Id rem SupCount + 1, | |||
Index = erlang:phash2(Id, SupCount) + 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if phash makes a better distribution than a simple rem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
No description provided.